Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Apr 26, 2022
1 parent 25647d8 commit dc36f16
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/rpc/rpc_01-system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,19 @@ func TestSystemRPC(t *testing.T) {
return false, nil // retry
}

bestBlockNumber := response[0].BestNumber
for _, peer := range response {
bestBlockNumbers := make([]uint64, len(response))
for i, peer := range response {
// wait for all peers to have the same best block number
sameBestBlockNumber := bestBlockNumber == peer.BestNumber
if peer.PeerID == "" || peer.BestHash.IsEmpty() || !sameBestBlockNumber {
bestBlockNumbers[i] = peer.BestNumber
if peer.PeerID == "" || peer.BestHash.IsEmpty() {
return false, nil // retry
}
}

mustEqualBlockNumber := bestBlockNumbers[0]
for _, bestBlockNumber := range bestBlockNumbers {
if mustEqualBlockNumber != bestBlockNumber {
t.Logf("Best block numbers are not equal: %v", bestBlockNumbers)
return false, nil // retry
}
}
Expand Down

0 comments on commit dc36f16

Please sign in to comment.