diff --git a/swarm/network/simulation/simulation.go b/swarm/network/simulation/simulation.go index 2045029b02..aa01f736fe 100644 --- a/swarm/network/simulation/simulation.go +++ b/swarm/network/simulation/simulation.go @@ -161,6 +161,14 @@ var maxParallelCleanups = 10 // simulation. func (s *Simulation) Close() { close(s.done) + // Close all connections before calling the Network Shutdown. + // It is possible that p2p.Server.Stop will block if there are + // existing connections. + for _, c := range s.Net.Conns { + if c.Up { + s.Net.Disconnect(c.One, c.Other) + } + } sem := make(chan struct{}, maxParallelCleanups) s.mu.RLock() cleanupFuncs := make([]func(), len(s.cleanupFuncs)) @@ -190,14 +198,6 @@ func (s *Simulation) Close() { close(s.runC) } s.shutdownWG.Wait() - // Close all connections before calling the Network Shutdown. - // It is possible that p2p.Server.Stop will block if there are - // existing connections. - for _, c := range s.Net.Conns { - if c.Up { - s.Net.Disconnect(c.One, c.Other) - } - } s.Net.Shutdown() }