Skip to content

Commit

Permalink
[FAB-13366] fix gossip state flake
Browse files Browse the repository at this point in the history
This commit removes time.Sleep() and instead waiting for peer to get
connected with bootstrap peer to build membership before sending state
message.

Change-Id: If132432a710e3006fc9de0e9ea051709e6edbde6
Signed-off-by: Artem Barger <bartem@il.ibm.com>
  • Loading branch information
C0rWin committed Jan 12, 2019
1 parent 73cc36f commit 1b1118e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gossip/state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,6 @@ func TestGossipStateProvider_TestStateMessages(t *testing.T) {
t.Log("Peer node got an answer, ", msg)
assert.True(t, msg.GetGossipMessage().GetStateResponse() != nil)
wg.Done()

}()

readyCh := make(chan struct{})
Expand All @@ -1104,11 +1103,12 @@ func TestGossipStateProvider_TestStateMessages(t *testing.T) {
readyCh <- struct{}{}
}()

time.Sleep(time.Duration(5) * time.Second)
t.Log("Sending gossip message with remote state request")

chainID := common.ChainID(util.GetTestChainID())
waitUntilTrueOrTimeout(t, func() bool {
return len(peer.g.PeersOfChannel(chainID)) == 1
}, 30*time.Second)

t.Log("Sending gossip message with remote state request")
peer.g.Send(&proto.GossipMessage{
Content: &proto.GossipMessage_StateRequest{StateRequest: &proto.RemoteStateRequest{StartSeqNum: 0, EndSeqNum: 1}},
}, &comm.RemotePeer{Endpoint: peer.g.PeersOfChannel(chainID)[0].Endpoint, PKIID: peer.g.PeersOfChannel(chainID)[0].PKIid})
Expand Down

0 comments on commit 1b1118e

Please sign in to comment.