Commit 74e0e4b7 authored by yacovm's avatar yacovm Committed by Yacov Manevich
Browse files

[FAB-15201] Fix TestSend flake

The test ensures that a certain amount of sends were invoked on the fake
gRPC stream, but it atomically increments it after writing to a channel
instead of first atomically incrementing and then writing to the channel
(which signals the test goroutine to asserting).

Change-Id: I1023685bfc3cf7cf33d7a18136578b3fb075fa30
Signed-off-by: default avataryacovm <>
parent b54abecb
......@@ -144,8 +144,8 @@ func TestSend(t *testing.T) {
stream.On("Send", mock.Anything).Return(func(*orderer.StepRequest) error {
defer l.Unlock()
sent <- struct{}{}
atomic.AddUint32(&sendCalls, 1)
sent <- struct{}{}
return tst.sendReturns
......@@ -241,12 +241,10 @@ func TestSend(t *testing.T) {
// Ensure that if we succeeded - only 1 stream was created despite 2 calls
// to Send() were made
err := testCase.method(rpc)
if testCase.expectedErr == "" {
assert.NoError(t, err)
assert.Equal(t, int(atomic.LoadUint32(&sendCalls)), 2)
assert.Equal(t, 2, int(atomic.LoadUint32(&sendCalls)))
client.AssertNumberOfCalls(t, "Step", 1)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment