Skip to content

Commit b5cbbe1

Browse files
ucwongenriquefynn
authored andcommitted
p2p/discv5, p2p/testing: add missing Timer.Stop calls in tests (ethereum#20869)
1 parent 365e0d7 commit b5cbbe1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

p2p/discv5/sim_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func TestSimRandomResolve(t *testing.T) {
4343

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

5758
time.Sleep(3 * time.Hour)
58-
launcher.Stop()
5959
sim.shutdown()
6060
sim.printStats()
6161
}
@@ -196,6 +196,7 @@ func randomResolves(t *testing.T, s *simulation, net *Network) {
196196
}
197197

198198
timer := time.NewTimer(randtime())
199+
defer timer.Stop()
199200
for {
200201
select {
201202
case <-timer.C:

p2p/testing/protocolsession.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ func (s *ProtocolSession) testExchange(e Exchange) error {
242242
t = 2000 * time.Millisecond
243243
}
244244
alarm := time.NewTimer(t)
245+
defer alarm.Stop()
245246
select {
246247
case err := <-errc:
247248
return err

0 commit comments

Comments
 (0)