Skip to content

Commit

Permalink
Merge "Gossip certStore test fix"
Browse files Browse the repository at this point in the history
  • Loading branch information
mastersingh24 authored and Gerrit Code Review committed Dec 24, 2016
2 parents e757dbf + 4d39ecd commit ec550b2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions gossip/gossip/certstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package gossip

import (
"sync"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -132,15 +131,21 @@ func testCertificateUpdate(t *testing.T, updateFactory func(uint64) comm.Receive

wg := sync.WaitGroup{}
wg.Add(1)
sentHello := int32(0)
sentHello := false
sentDataReq := false
l := sync.Mutex{}
sender.On("Send", mock.Anything, mock.Anything).Run(func(arg mock.Arguments) {
msg := arg.Get(0).(*proto.GossipMessage)
if hello := msg.GetHello(); hello != nil && atomic.LoadInt32(&sentHello) == int32(0) {
atomic.StoreInt32(&sentHello, int32(1))
l.Lock()
defer l.Unlock()

if hello := msg.GetHello(); hello != nil && !sentHello {
sentHello = true
go certStore.handleMessage(createDigest(hello.Nonce))
}

if dataReq := msg.GetDataReq(); dataReq != nil {
if dataReq := msg.GetDataReq(); dataReq != nil && !sentDataReq {
sentDataReq = true
certStore.handleMessage(updateFactory(dataReq.Nonce))
wg.Done()
}
Expand Down

0 comments on commit ec550b2

Please sign in to comment.