Skip to content

Commit

Permalink
p2p/discv5, p2p/testing: add missing Timer.Stop calls in tests (#20869)
Browse files Browse the repository at this point in the history
  • Loading branch information
ucwong committed Apr 2, 2020
1 parent 37d6357 commit 0c359e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion p2p/discv5/sim_test.go
Expand Up @@ -43,6 +43,7 @@ func TestSimRandomResolve(t *testing.T) {

// A new node joins every 10s.
launcher := time.NewTicker(10 * time.Second)
defer launcher.Stop()
go func() {
for range launcher.C {
net := sim.launchNode(false)
Expand All @@ -55,7 +56,6 @@ func TestSimRandomResolve(t *testing.T) {
}()

time.Sleep(3 * time.Hour)
launcher.Stop()
sim.shutdown()
sim.printStats()
}
Expand Down Expand Up @@ -196,6 +196,7 @@ func randomResolves(t *testing.T, s *simulation, net *Network) {
}

timer := time.NewTimer(randtime())
defer timer.Stop()
for {
select {
case <-timer.C:
Expand Down
1 change: 1 addition & 0 deletions p2p/testing/protocolsession.go
Expand Up @@ -242,6 +242,7 @@ func (s *ProtocolSession) testExchange(e Exchange) error {
t = 2000 * time.Millisecond
}
alarm := time.NewTimer(t)
defer alarm.Stop()
select {
case err := <-errc:
return err
Expand Down

0 comments on commit 0c359e4

Please sign in to comment.