forked from cerc-io/plugeth
swarm/pss: Remove pss service leak in test (#18992)
This commit is contained in:
parent
1c3aa8d9b1
commit
7c60d0a6a2
@ -54,6 +54,7 @@ func TestForwardBasic(t *testing.T) {
|
|||||||
|
|
||||||
kad := network.NewKademlia(base[:], network.NewKadParams())
|
kad := network.NewKademlia(base[:], network.NewKadParams())
|
||||||
ps := createPss(t, kad)
|
ps := createPss(t, kad)
|
||||||
|
defer ps.Stop()
|
||||||
addPeers(kad, peerAddresses)
|
addPeers(kad, peerAddresses)
|
||||||
|
|
||||||
const firstNearest = depth * 2 // shallowest peer in the nearest neighbours' bin
|
const firstNearest = depth * 2 // shallowest peer in the nearest neighbours' bin
|
||||||
|
@ -170,6 +170,7 @@ func TestCache(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ps := newTestPss(privkey, nil, nil)
|
ps := newTestPss(privkey, nil, nil)
|
||||||
|
defer ps.Stop()
|
||||||
pp := NewPssParams().WithPrivateKey(privkey)
|
pp := NewPssParams().WithPrivateKey(privkey)
|
||||||
data := []byte("foo")
|
data := []byte("foo")
|
||||||
datatwo := []byte("bar")
|
datatwo := []byte("bar")
|
||||||
@ -648,6 +649,7 @@ func TestMessageProcessing(t *testing.T) {
|
|||||||
addr := make([]byte, 32)
|
addr := make([]byte, 32)
|
||||||
addr[0] = 0x01
|
addr[0] = 0x01
|
||||||
ps := newTestPss(privkey, network.NewKademlia(addr, network.NewKadParams()), NewPssParams())
|
ps := newTestPss(privkey, network.NewKademlia(addr, network.NewKadParams()), NewPssParams())
|
||||||
|
defer ps.Stop()
|
||||||
|
|
||||||
// message should pass
|
// message should pass
|
||||||
msg := newPssMsg(&msgParams{})
|
msg := newPssMsg(&msgParams{})
|
||||||
@ -780,6 +782,7 @@ func TestKeys(t *testing.T) {
|
|||||||
t.Fatalf("failed to retrieve 'their' private key")
|
t.Fatalf("failed to retrieve 'their' private key")
|
||||||
}
|
}
|
||||||
ps := newTestPss(ourprivkey, nil, nil)
|
ps := newTestPss(ourprivkey, nil, nil)
|
||||||
|
defer ps.Stop()
|
||||||
|
|
||||||
// set up peer with mock address, mapped to mocked publicaddress and with mocked symkey
|
// set up peer with mock address, mapped to mocked publicaddress and with mocked symkey
|
||||||
addr := make(PssAddress, 32)
|
addr := make(PssAddress, 32)
|
||||||
@ -829,6 +832,7 @@ func TestGetPublickeyEntries(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ps := newTestPss(privkey, nil, nil)
|
ps := newTestPss(privkey, nil, nil)
|
||||||
|
defer ps.Stop()
|
||||||
|
|
||||||
peeraddr := network.RandomAddr().Over()
|
peeraddr := network.RandomAddr().Over()
|
||||||
topicaddr := make(map[Topic]PssAddress)
|
topicaddr := make(map[Topic]PssAddress)
|
||||||
@ -932,6 +936,7 @@ func TestPeerCapabilityMismatch(t *testing.T) {
|
|||||||
Payload: &whisper.Envelope{},
|
Payload: &whisper.Envelope{},
|
||||||
}
|
}
|
||||||
ps := newTestPss(privkey, kad, nil)
|
ps := newTestPss(privkey, kad, nil)
|
||||||
|
defer ps.Stop()
|
||||||
|
|
||||||
// run the forward
|
// run the forward
|
||||||
// it is enough that it completes; trying to send to incapable peers would create segfault
|
// it is enough that it completes; trying to send to incapable peers would create segfault
|
||||||
@ -950,6 +955,7 @@ func TestRawAllow(t *testing.T) {
|
|||||||
baseAddr := network.RandomAddr()
|
baseAddr := network.RandomAddr()
|
||||||
kad := network.NewKademlia((baseAddr).Over(), network.NewKadParams())
|
kad := network.NewKademlia((baseAddr).Over(), network.NewKadParams())
|
||||||
ps := newTestPss(privKey, kad, nil)
|
ps := newTestPss(privKey, kad, nil)
|
||||||
|
defer ps.Stop()
|
||||||
topic := BytesToTopic([]byte{0x2a})
|
topic := BytesToTopic([]byte{0x2a})
|
||||||
|
|
||||||
// create handler innards that increments every time a message hits it
|
// create handler innards that increments every time a message hits it
|
||||||
@ -1691,6 +1697,7 @@ func benchmarkSymKeySend(b *testing.B) {
|
|||||||
keys, err := wapi.NewKeyPair(ctx)
|
keys, err := wapi.NewKeyPair(ctx)
|
||||||
privkey, err := w.GetPrivateKey(keys)
|
privkey, err := w.GetPrivateKey(keys)
|
||||||
ps := newTestPss(privkey, nil, nil)
|
ps := newTestPss(privkey, nil, nil)
|
||||||
|
defer ps.Stop()
|
||||||
msg := make([]byte, msgsize)
|
msg := make([]byte, msgsize)
|
||||||
rand.Read(msg)
|
rand.Read(msg)
|
||||||
topic := BytesToTopic([]byte("foo"))
|
topic := BytesToTopic([]byte("foo"))
|
||||||
@ -1735,6 +1742,7 @@ func benchmarkAsymKeySend(b *testing.B) {
|
|||||||
keys, err := wapi.NewKeyPair(ctx)
|
keys, err := wapi.NewKeyPair(ctx)
|
||||||
privkey, err := w.GetPrivateKey(keys)
|
privkey, err := w.GetPrivateKey(keys)
|
||||||
ps := newTestPss(privkey, nil, nil)
|
ps := newTestPss(privkey, nil, nil)
|
||||||
|
defer ps.Stop()
|
||||||
msg := make([]byte, msgsize)
|
msg := make([]byte, msgsize)
|
||||||
rand.Read(msg)
|
rand.Read(msg)
|
||||||
topic := BytesToTopic([]byte("foo"))
|
topic := BytesToTopic([]byte("foo"))
|
||||||
@ -1785,6 +1793,7 @@ func benchmarkSymkeyBruteforceChangeaddr(b *testing.B) {
|
|||||||
} else {
|
} else {
|
||||||
ps = newTestPss(privkey, nil, nil)
|
ps = newTestPss(privkey, nil, nil)
|
||||||
}
|
}
|
||||||
|
defer ps.Stop()
|
||||||
topic := BytesToTopic([]byte("foo"))
|
topic := BytesToTopic([]byte("foo"))
|
||||||
for i := 0; i < int(keycount); i++ {
|
for i := 0; i < int(keycount); i++ {
|
||||||
to := make(PssAddress, 32)
|
to := make(PssAddress, 32)
|
||||||
@ -1868,6 +1877,7 @@ func benchmarkSymkeyBruteforceSameaddr(b *testing.B) {
|
|||||||
} else {
|
} else {
|
||||||
ps = newTestPss(privkey, nil, nil)
|
ps = newTestPss(privkey, nil, nil)
|
||||||
}
|
}
|
||||||
|
defer ps.Stop()
|
||||||
topic := BytesToTopic([]byte("foo"))
|
topic := BytesToTopic([]byte("foo"))
|
||||||
for i := 0; i < int(keycount); i++ {
|
for i := 0; i < int(keycount); i++ {
|
||||||
copy(addr[i], network.RandomAddr().Over())
|
copy(addr[i], network.RandomAddr().Over())
|
||||||
|
Loading…
Reference in New Issue
Block a user