Skip to content

Commit 11f3d0c

Browse files
committed
Add sync.WaitGroup to the payloads buffer test
In order to prevent payloads buffer tests fail intermitently added syncronization to make sure assertion won't happen before message appears in the channel. Change-Id: I141492f87c58cbcecb82b8aa21feafce3da83785 Signed-off-by: Artem Barger <[email protected]>
1 parent 37a662f commit 11f3d0c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gossip/state/payloads_buffer_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,13 @@ func TestPayloadsBufferImpl_ConcurrentPush(t *testing.T) {
145145
var errors []error
146146

147147
ready := int32(0)
148+
readyWG := sync.WaitGroup{}
149+
readyWG.Add(1)
148150
go func() {
149-
150151
// Wait for next expected block to arrive
151152
<-buffer.Ready()
152153
atomic.AddInt32(&ready, 1)
154+
readyWG.Done()
153155
}()
154156

155157
for i := 0; i < concurrency; i++ {
@@ -171,6 +173,7 @@ func TestPayloadsBufferImpl_ConcurrentPush(t *testing.T) {
171173
}
172174
}
173175

176+
readyWG.Wait()
174177
assert.Equal(t, int32(1), atomic.LoadInt32(&ready))
175178
assert.Equal(t, 1, success)
176179
// Buffer size has to be only one

0 commit comments

Comments
 (0)