aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorSonic <sonic@cobinhood.com>2018-10-15 12:53:29 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:49 +0800
commit5506c2ae4ac14b0644f1ef89a7cefae35bd016cd (patch)
treeb32643511c5b6680c8f7ffd7546663dcb793eb71 /dex
parentaa5b35ed44d5ec38599aa9d7bb9232153bf8d81c (diff)
downloaddexon-5506c2ae4ac14b0644f1ef89a7cefae35bd016cd.tar
dexon-5506c2ae4ac14b0644f1ef89a7cefae35bd016cd.tar.gz
dexon-5506c2ae4ac14b0644f1ef89a7cefae35bd016cd.tar.bz2
dexon-5506c2ae4ac14b0644f1ef89a7cefae35bd016cd.tar.lz
dexon-5506c2ae4ac14b0644f1ef89a7cefae35bd016cd.tar.xz
dexon-5506c2ae4ac14b0644f1ef89a7cefae35bd016cd.tar.zst
dexon-5506c2ae4ac14b0644f1ef89a7cefae35bd016cd.zip
dex: fix flaky test
Diffstat (limited to 'dex')
-rw-r--r--dex/protocol_test.go12
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
+ }
+ }
+}