diff options
author | Sonic <sonic@cobinhood.com> | 2018-10-15 12:53:29 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:23:39 +0800 |
commit | 378251a5e32db4e6e3e964128e0eae0809d2d878 (patch) | |
tree | 4ee411de57313aafe3b5b8c92598e9073ecc1db5 /dex | |
parent | 7d27d334ed128bf528c8a7fc16674d0a29481087 (diff) | |
download | go-tangerine-378251a5e32db4e6e3e964128e0eae0809d2d878.tar go-tangerine-378251a5e32db4e6e3e964128e0eae0809d2d878.tar.gz go-tangerine-378251a5e32db4e6e3e964128e0eae0809d2d878.tar.bz2 go-tangerine-378251a5e32db4e6e3e964128e0eae0809d2d878.tar.lz go-tangerine-378251a5e32db4e6e3e964128e0eae0809d2d878.tar.xz go-tangerine-378251a5e32db4e6e3e964128e0eae0809d2d878.tar.zst go-tangerine-378251a5e32db4e6e3e964128e0eae0809d2d878.zip |
dex: fix flaky test
Diffstat (limited to 'dex')
-rw-r--r-- | dex/protocol_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/dex/protocol_test.go b/dex/protocol_test.go index a26a40feb..4bb3dc9e8 100644 --- a/dex/protocol_test.go +++ b/dex/protocol_test.go @@ -406,6 +406,7 @@ func TestSendLatticeBlock(t *testing.T) { }, } + waitForRegister(pm, 1) pm.BroadcastLatticeBlock(&block) msg, err := p.app.ReadMsg() if err != nil { @@ -552,6 +553,7 @@ func TestSendVote(t *testing.T) { wg.Add(1) go checkvote(p, tt.isReceiver) } + waitForRegister(pm, len(testPeers)) pm.BroadcastVote(&vote) wg.Wait() } @@ -725,6 +727,7 @@ func TestSendAgreement(t *testing.T) { Votes: []coreTypes.Vote{vote}, } + waitForRegister(pm, 1) pm.BroadcastAgreementResult(&agreement) msg, err := p.app.ReadMsg() if err != nil { @@ -785,6 +788,7 @@ func TestSendRandomness(t *testing.T) { Randomness: []byte{7, 7, 7, 7}, } + waitForRegister(pm, 1) pm.BroadcastRandomnessResult(&randomness) msg, err := p.app.ReadMsg() if err != nil { @@ -802,3 +806,11 @@ func TestSendRandomness(t *testing.T) { t.Errorf("agreement mismatch") } } + +func waitForRegister(pm *ProtocolManager, num int) { + for { + if pm.peers.Len() >= num { + return + } + } +} |