From 0c359e4b9a3f3418245ed8ef131e2ea4e4bab792 Mon Sep 17 00:00:00 2001 From: ucwong Date: Thu, 2 Apr 2020 22:03:40 +0800 Subject: [PATCH] p2p/discv5, p2p/testing: add missing Timer.Stop calls in tests (#20869) --- p2p/discv5/sim_test.go | 3 ++- p2p/testing/protocolsession.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/p2p/discv5/sim_test.go b/p2p/discv5/sim_test.go index aac26d9c4..3d1e610d3 100644 --- a/p2p/discv5/sim_test.go +++ b/p2p/discv5/sim_test.go @@ -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) @@ -55,7 +56,6 @@ func TestSimRandomResolve(t *testing.T) { }() time.Sleep(3 * time.Hour) - launcher.Stop() sim.shutdown() sim.printStats() } @@ -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: diff --git a/p2p/testing/protocolsession.go b/p2p/testing/protocolsession.go index e3a3915a8..58dac93c3 100644 --- a/p2p/testing/protocolsession.go +++ b/p2p/testing/protocolsession.go @@ -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