Skip to content

Commit 6845945

Browse files
janosdshulyak
authored andcommitted
swarm/network: fix data race in TestNetworkID test (ethereum#18460)
(cherry picked from commit 96c7c18)
1 parent d901911 commit 6845945

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

swarm/network/networkid_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,12 @@ func TestNetworkID(t *testing.T) {
7676
if err != nil {
7777
t.Fatalf("Error setting up network: %v", err)
7878
}
79-
defer func() {
80-
//shutdown the snapshot network
81-
log.Trace("Shutting down network")
82-
net.Shutdown()
83-
}()
8479
//let's sleep to ensure all nodes are connected
8580
time.Sleep(1 * time.Second)
81+
// shutdown the the network to avoid race conditions
82+
// on accessing kademlias global map while network nodes
83+
// are accepting messages
84+
net.Shutdown()
8685
//for each group sharing the same network ID...
8786
for _, netIDGroup := range nodeMap {
8887
log.Trace("netIDGroup size", "size", len(netIDGroup))

0 commit comments

Comments
 (0)