Skip to content

Commit ad3e63b

Browse files
[FAB-3841] Gossip TestCertRevocation
Total time allocated to one round of pull algorithm in test was less that time allocated to its sub-parts, that caused (rarelly) to 2 pull routines to run in parallel and interfire one with another. Change-Id: I63603f1418f565fc1a56cbb097ed707e1182f38b Signed-off-by: Gennady Laventman <gennady@il.ibm.com>
1 parent 1cdbfc0 commit ad3e63b

File tree

1 file changed

+7
-31
lines changed

1 file changed

+7
-31
lines changed

gossip/gossip/certstore_test.go

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ func TestCertRevocation(t *testing.T) {
151151

152152
sentHello := false
153153
l := sync.Mutex{}
154-
senderMock := mock.Mock{}
155-
senderMock.On("Send", mock.Anything, mock.Anything).Run(func(arg mock.Arguments) {
154+
sender.Mock = mock.Mock{}
155+
sender.On("Send", mock.Anything, mock.Anything).Run(func(arg mock.Arguments) {
156156
msg := arg.Get(0).(*proto.SignedGossipMessage)
157157
l.Lock()
158158
defer l.Unlock()
@@ -176,11 +176,10 @@ func TestCertRevocation(t *testing.T) {
176176
askedForIdentity <- struct{}{}
177177
}
178178
})
179-
sender.Mock = senderMock
180179
testCertificateUpdate(t, true, cStore)
181180
// Shouldn't have asked, because already got identity
182181
select {
183-
case <-time.After(time.Second * 3):
182+
case <-time.After(time.Second * 5):
184183
case <-askedForIdentity:
185184
assert.Fail(t, "Shouldn't have asked for an identity, becase we already have it")
186185
}
@@ -190,33 +189,10 @@ func TestCertRevocation(t *testing.T) {
190189
cStore.listRevokedPeers(func(id api.PeerIdentityType) bool {
191190
return string(id) == "B"
192191
})
193-
sentHello = false
194-
l = sync.Mutex{}
195-
senderMock = mock.Mock{}
196-
senderMock.On("Send", mock.Anything, mock.Anything).Run(func(arg mock.Arguments) {
197-
msg := arg.Get(0).(*proto.SignedGossipMessage)
198-
l.Lock()
199-
defer l.Unlock()
200-
201-
if hello := msg.GetHello(); hello != nil && !sentHello {
202-
sentHello = true
203-
dig := &proto.GossipMessage{
204-
Tag: proto.GossipMessage_EMPTY,
205-
Content: &proto.GossipMessage_DataDig{
206-
DataDig: &proto.DataDigest{
207-
Nonce: hello.Nonce,
208-
MsgType: proto.PullMsgType_IDENTITY_MSG,
209-
Digests: []string{"B"},
210-
},
211-
},
212-
}
213-
go cStore.handleMessage(&sentMsg{msg: dig.NoopSign()})
214-
}
215192

216-
if dataReq := msg.GetDataReq(); dataReq != nil {
217-
askedForIdentity <- struct{}{}
218-
}
219-
})
193+
l.Lock()
194+
sentHello = false
195+
l.Unlock()
220196

221197
select {
222198
case <-time.After(time.Second * 5):
@@ -435,7 +411,7 @@ func createObjects(updateFactory func(uint64) proto.ReceivedMessage, msgCons pro
435411
config := pull.Config{
436412
MsgType: proto.PullMsgType_IDENTITY_MSG,
437413
PeerCountToSelect: 1,
438-
PullInterval: time.Millisecond * 500,
414+
PullInterval: time.Second,
439415
Tag: proto.GossipMessage_EMPTY,
440416
Channel: nil,
441417
ID: "id1",

0 commit comments

Comments
 (0)