Skip to content

Commit 7c60d0a

Browse files
nolashnonsense
authored andcommitted
swarm/pss: Remove pss service leak in test (ethereum#18992)
1 parent 1c3aa8d commit 7c60d0a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

swarm/pss/forwarding_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func TestForwardBasic(t *testing.T) {
5454

5555
kad := network.NewKademlia(base[:], network.NewKadParams())
5656
ps := createPss(t, kad)
57+
defer ps.Stop()
5758
addPeers(kad, peerAddresses)
5859

5960
const firstNearest = depth * 2 // shallowest peer in the nearest neighbours' bin

swarm/pss/pss_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ func TestCache(t *testing.T) {
170170
t.Fatal(err)
171171
}
172172
ps := newTestPss(privkey, nil, nil)
173+
defer ps.Stop()
173174
pp := NewPssParams().WithPrivateKey(privkey)
174175
data := []byte("foo")
175176
datatwo := []byte("bar")
@@ -648,6 +649,7 @@ func TestMessageProcessing(t *testing.T) {
648649
addr := make([]byte, 32)
649650
addr[0] = 0x01
650651
ps := newTestPss(privkey, network.NewKademlia(addr, network.NewKadParams()), NewPssParams())
652+
defer ps.Stop()
651653

652654
// message should pass
653655
msg := newPssMsg(&msgParams{})
@@ -780,6 +782,7 @@ func TestKeys(t *testing.T) {
780782
t.Fatalf("failed to retrieve 'their' private key")
781783
}
782784
ps := newTestPss(ourprivkey, nil, nil)
785+
defer ps.Stop()
783786

784787
// set up peer with mock address, mapped to mocked publicaddress and with mocked symkey
785788
addr := make(PssAddress, 32)
@@ -829,6 +832,7 @@ func TestGetPublickeyEntries(t *testing.T) {
829832
t.Fatal(err)
830833
}
831834
ps := newTestPss(privkey, nil, nil)
835+
defer ps.Stop()
832836

833837
peeraddr := network.RandomAddr().Over()
834838
topicaddr := make(map[Topic]PssAddress)
@@ -932,6 +936,7 @@ func TestPeerCapabilityMismatch(t *testing.T) {
932936
Payload: &whisper.Envelope{},
933937
}
934938
ps := newTestPss(privkey, kad, nil)
939+
defer ps.Stop()
935940

936941
// run the forward
937942
// it is enough that it completes; trying to send to incapable peers would create segfault
@@ -950,6 +955,7 @@ func TestRawAllow(t *testing.T) {
950955
baseAddr := network.RandomAddr()
951956
kad := network.NewKademlia((baseAddr).Over(), network.NewKadParams())
952957
ps := newTestPss(privKey, kad, nil)
958+
defer ps.Stop()
953959
topic := BytesToTopic([]byte{0x2a})
954960

955961
// create handler innards that increments every time a message hits it
@@ -1691,6 +1697,7 @@ func benchmarkSymKeySend(b *testing.B) {
16911697
keys, err := wapi.NewKeyPair(ctx)
16921698
privkey, err := w.GetPrivateKey(keys)
16931699
ps := newTestPss(privkey, nil, nil)
1700+
defer ps.Stop()
16941701
msg := make([]byte, msgsize)
16951702
rand.Read(msg)
16961703
topic := BytesToTopic([]byte("foo"))
@@ -1735,6 +1742,7 @@ func benchmarkAsymKeySend(b *testing.B) {
17351742
keys, err := wapi.NewKeyPair(ctx)
17361743
privkey, err := w.GetPrivateKey(keys)
17371744
ps := newTestPss(privkey, nil, nil)
1745+
defer ps.Stop()
17381746
msg := make([]byte, msgsize)
17391747
rand.Read(msg)
17401748
topic := BytesToTopic([]byte("foo"))
@@ -1785,6 +1793,7 @@ func benchmarkSymkeyBruteforceChangeaddr(b *testing.B) {
17851793
} else {
17861794
ps = newTestPss(privkey, nil, nil)
17871795
}
1796+
defer ps.Stop()
17881797
topic := BytesToTopic([]byte("foo"))
17891798
for i := 0; i < int(keycount); i++ {
17901799
to := make(PssAddress, 32)
@@ -1868,6 +1877,7 @@ func benchmarkSymkeyBruteforceSameaddr(b *testing.B) {
18681877
} else {
18691878
ps = newTestPss(privkey, nil, nil)
18701879
}
1880+
defer ps.Stop()
18711881
topic := BytesToTopic([]byte("foo"))
18721882
for i := 0; i < int(keycount); i++ {
18731883
copy(addr[i], network.RandomAddr().Over())

0 commit comments

Comments
 (0)