diff options
author | Sonic <sonic@cobinhood.com> | 2018-10-15 12:53:29 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 13:49:53 +0800 |
commit | c914fae82678b4748d61cf083ce3e5b9e5044ecc (patch) | |
tree | 3c777a13611d559809b97ff669ea202f1aae4b73 | |
parent | 08c7e4c7c6fccf894c0e004a416355cfc82ec5d7 (diff) | |
download | dexon-c914fae82678b4748d61cf083ce3e5b9e5044ecc.tar dexon-c914fae82678b4748d61cf083ce3e5b9e5044ecc.tar.gz dexon-c914fae82678b4748d61cf083ce3e5b9e5044ecc.tar.bz2 dexon-c914fae82678b4748d61cf083ce3e5b9e5044ecc.tar.lz dexon-c914fae82678b4748d61cf083ce3e5b9e5044ecc.tar.xz dexon-c914fae82678b4748d61cf083ce3e5b9e5044ecc.tar.zst dexon-c914fae82678b4748d61cf083ce3e5b9e5044ecc.zip |
dex: fix flaky test
-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 + } + } +} |