Unverified Commit 0c359e4b authored by ucwong's avatar ucwong Committed by GitHub

p2p/discv5, p2p/testing: add missing Timer.Stop calls in tests (#20869)

parent 37d63578
...@@ -43,6 +43,7 @@ func TestSimRandomResolve(t *testing.T) { ...@@ -43,6 +43,7 @@ func TestSimRandomResolve(t *testing.T) {
// A new node joins every 10s. // A new node joins every 10s.
launcher := time.NewTicker(10 * time.Second) launcher := time.NewTicker(10 * time.Second)
defer launcher.Stop()
go func() { go func() {
for range launcher.C { for range launcher.C {
net := sim.launchNode(false) net := sim.launchNode(false)
...@@ -55,7 +56,6 @@ func TestSimRandomResolve(t *testing.T) { ...@@ -55,7 +56,6 @@ func TestSimRandomResolve(t *testing.T) {
}() }()
time.Sleep(3 * time.Hour) time.Sleep(3 * time.Hour)
launcher.Stop()
sim.shutdown() sim.shutdown()
sim.printStats() sim.printStats()
} }
...@@ -196,6 +196,7 @@ func randomResolves(t *testing.T, s *simulation, net *Network) { ...@@ -196,6 +196,7 @@ func randomResolves(t *testing.T, s *simulation, net *Network) {
} }
timer := time.NewTimer(randtime()) timer := time.NewTimer(randtime())
defer timer.Stop()
for { for {
select { select {
case <-timer.C: case <-timer.C:
......
...@@ -242,6 +242,7 @@ func (s *ProtocolSession) testExchange(e Exchange) error { ...@@ -242,6 +242,7 @@ func (s *ProtocolSession) testExchange(e Exchange) error {
t = 2000 * time.Millisecond t = 2000 * time.Millisecond
} }
alarm := time.NewTimer(t) alarm := time.NewTimer(t)
defer alarm.Stop()
select { select {
case err := <-errc: case err := <-errc:
return err return err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment