Skip to content

Commit

Permalink
rpcclient: fix race in TestWSClientNonBlockingEvents
Browse files Browse the repository at this point in the history
The race is probably caused by the fact that accessing receivers
list of WSClient under rlock requires some time. Technically, it may
be helpful to increase timeouts for the receivers checking operation,
but we can add one more condition to ensure that at least maximum
number of messages was received by the buffered receiver.

This test can't be reproduced on my machine, thus I'd suggest to keep
an eye on it in GH workflows for some time.

Close #3005.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Aug 29, 2023
1 parent d7fb933 commit 304ccc1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/rpcclient/wsclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,13 @@ func TestWSClientNonBlockingEvents(t *testing.T) {
return blocksSent.Load()
}, time.Second, 100*time.Millisecond)

// Check that block receiver channel was removed from the receivers list due to overflow.
// Check that block receiver channel is full.
require.Eventually(t, func() bool {
return len(bCh) == chCap
}, 2*time.Second, 200*time.Millisecond)

// Check that block receiver channel was removed from the receivers list due
// to overflow.
require.Eventually(t, func() bool {
wsc.subscriptionsLock.RLock()
defer wsc.subscriptionsLock.RUnlock()
Expand Down

0 comments on commit 304ccc1

Please sign in to comment.