Skip to content

Commit

Permalink
update mempool reactor tests with multiplexReactor closing
Browse files Browse the repository at this point in the history
  • Loading branch information
JayT106 committed Dec 5, 2022
1 parent 613b5e0 commit 33a5e8b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mempool/v0/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func makeAndConnectReactors(t *testing.T, config *cfg.Config, n int) []*Reactor
reactors[i].SetLogger(logger.With("validator", i))
}

p2p.MakeConnectedSwitches(config.P2P, n, func(i int, s *p2p.Switch) *p2p.Switch {
_, mts := p2p.MakeConnectedSwitchesWithMultiplexTransports(config.P2P, n, func(i int, s *p2p.Switch) *p2p.Switch {
s.AddReactor("MEMPOOL", reactors[i])
return s

Expand All @@ -324,6 +324,10 @@ func makeAndConnectReactors(t *testing.T, config *cfg.Config, n int) []*Reactor
_ = reactor.Switch.Stop()
}

for _, mt := range mts {
_ = mt.Close()
}

// check that we are not leaking any go-routines
// i.e. broadcastTxRoutine finishes when peer is stopped
leaktest.CheckTimeout(t, 10*time.Second)()
Expand Down
6 changes: 5 additions & 1 deletion mempool/v1/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func makeAndConnectReactors(t *testing.T, config *cfg.Config, n int) []*Reactor
reactors[i].SetLogger(logger.With("validator", i))
}

p2p.MakeConnectedSwitches(config.P2P, n, func(i int, s *p2p.Switch) *p2p.Switch {
_, mts := p2p.MakeConnectedSwitchesWithMultiplexTransports(config.P2P, n, func(i int, s *p2p.Switch) *p2p.Switch {
s.AddReactor("MEMPOOL", reactors[i])
return s

Expand All @@ -120,6 +120,10 @@ func makeAndConnectReactors(t *testing.T, config *cfg.Config, n int) []*Reactor
_ = reactor.Switch.Stop()
}

for _, mt := range mts {
_ = mt.Close()
}

// check that we are not leaking any go-routines
// i.e. broadcastTxRoutine finishes when peer is stopped
leaktest.CheckTimeout(t, 10*time.Second)()
Expand Down

0 comments on commit 33a5e8b

Please sign in to comment.