Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swarm/pss: Remove pss service leak in test #18992

Merged
merged 2 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions swarm/pss/forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func TestForwardBasic(t *testing.T) {

kad := network.NewKademlia(base[:], network.NewKadParams())
ps := createPss(t, kad)
defer ps.Stop()
addPeers(kad, peerAddresses)

const firstNearest = depth * 2 // shallowest peer in the nearest neighbours' bin
Expand Down
10 changes: 10 additions & 0 deletions swarm/pss/pss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func TestCache(t *testing.T) {
t.Fatal(err)
}
ps := newTestPss(privkey, nil, nil)
defer ps.Stop()
pp := NewPssParams().WithPrivateKey(privkey)
data := []byte("foo")
datatwo := []byte("bar")
Expand Down Expand Up @@ -648,6 +649,7 @@ func TestMessageProcessing(t *testing.T) {
addr := make([]byte, 32)
addr[0] = 0x01
ps := newTestPss(privkey, network.NewKademlia(addr, network.NewKadParams()), NewPssParams())
defer ps.Stop()

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

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

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

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

// create handler innards that increments every time a message hits it
Expand Down Expand Up @@ -1691,6 +1697,7 @@ func benchmarkSymKeySend(b *testing.B) {
keys, err := wapi.NewKeyPair(ctx)
privkey, err := w.GetPrivateKey(keys)
ps := newTestPss(privkey, nil, nil)
defer ps.Stop()
msg := make([]byte, msgsize)
rand.Read(msg)
topic := BytesToTopic([]byte("foo"))
Expand Down Expand Up @@ -1735,6 +1742,7 @@ func benchmarkAsymKeySend(b *testing.B) {
keys, err := wapi.NewKeyPair(ctx)
privkey, err := w.GetPrivateKey(keys)
ps := newTestPss(privkey, nil, nil)
defer ps.Stop()
msg := make([]byte, msgsize)
rand.Read(msg)
topic := BytesToTopic([]byte("foo"))
Expand Down Expand Up @@ -1785,6 +1793,7 @@ func benchmarkSymkeyBruteforceChangeaddr(b *testing.B) {
} else {
ps = newTestPss(privkey, nil, nil)
}
defer ps.Stop()
topic := BytesToTopic([]byte("foo"))
for i := 0; i < int(keycount); i++ {
to := make(PssAddress, 32)
Expand Down Expand Up @@ -1868,6 +1877,7 @@ func benchmarkSymkeyBruteforceSameaddr(b *testing.B) {
} else {
ps = newTestPss(privkey, nil, nil)
}
defer ps.Stop()
topic := BytesToTopic([]byte("foo"))
for i := 0; i < int(keycount); i++ {
copy(addr[i], network.RandomAddr().Over())
Expand Down