diff options
author | Elad <theman@elad.im> | 2019-01-17 18:38:23 +0800 |
---|---|---|
committer | Rafael Matias <rafael@skyle.net> | 2019-02-19 19:55:18 +0800 |
commit | afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea (patch) | |
tree | cb971679f528aa46a7480fbb6944082f8996e7ee /swarm/network/protocol_test.go | |
parent | 1f1c751b6e4388f4534f294cd13250f1eb871de5 (diff) | |
download | dexon-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar dexon-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar.gz dexon-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar.bz2 dexon-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar.lz dexon-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar.xz dexon-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.tar.zst dexon-afb65f6ace9f319c2e4eb4d5d7dc4320c0dcaeea.zip |
swarm/network: fix data race warning on TestBzzHandshakeLightNode (#18459)
(cherry picked from commit 81e26d5a4837077d5fff17e7b461061b134a4a00)
Diffstat (limited to 'swarm/network/protocol_test.go')
-rw-r--r-- | swarm/network/protocol_test.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/swarm/network/protocol_test.go b/swarm/network/protocol_test.go index 58477a7b8..80d67e767 100644 --- a/swarm/network/protocol_test.go +++ b/swarm/network/protocol_test.go @@ -21,6 +21,7 @@ import ( "fmt" "os" "testing" + "time" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p" @@ -224,7 +225,7 @@ func TestBzzHandshakeLightNode(t *testing.T) { for _, test := range lightNodeTests { t.Run(test.name, func(t *testing.T) { randomAddr := RandomAddr() - pt := newBzzHandshakeTester(t, 1, randomAddr, false) + pt := newBzzHandshakeTester(nil, 1, randomAddr, false) // TODO change signature - t is not used anywhere node := pt.Nodes[0] addr := NewAddr(node) @@ -237,8 +238,14 @@ func TestBzzHandshakeLightNode(t *testing.T) { t.Fatal(err) } - if pt.bzz.handshakes[node.ID()].LightNode != test.lightNode { - t.Fatalf("peer LightNode flag is %v, should be %v", pt.bzz.handshakes[node.ID()].LightNode, test.lightNode) + select { + + case <-pt.bzz.handshakes[node.ID()].done: + if pt.bzz.handshakes[node.ID()].LightNode != test.lightNode { + t.Fatalf("peer LightNode flag is %v, should be %v", pt.bzz.handshakes[node.ID()].LightNode, test.lightNode) + } + case <-time.After(10 * time.Second): + t.Fatal("test timeout") } }) } |