From e69a3d9703f2f6e46ccdf2c2627b725b57eebbad Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Wed, 27 May 2020 13:49:57 +0200 Subject: [PATCH] rpc/test: wait for subscription in TestTxEventsSentWithBroadcastTxAsync (#4907) Mitigates race condition causing these test failures: ``` === RUN TestTxEventsSentWithBroadcastTxAsync === RUN TestTxEventsSentWithBroadcastTxAsync/*http.HTTP I[2020-05-25|12:29:08.477] Starting WSEvents service impl=WSEvents TestTxEventsSentWithBroadcastTxAsync/*http.HTTP: event_test.go:124: Error Trace: event_test.go:124 Error: Expected nil, but got: &errors.errorString{s:"timed out waiting for event"} Test: TestTxEventsSentWithBroadcastTxAsync/*http.HTTP Messages: 0: timed out waiting for event ``` --- rpc/client/event_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rpc/client/event_test.go b/rpc/client/event_test.go index a25b6ebb2..e6b5bd0c8 100644 --- a/rpc/client/event_test.go +++ b/rpc/client/event_test.go @@ -98,6 +98,9 @@ func testTxEventsSent(t *testing.T, broadcastMethod string) { defer c.Stop() } + // wait for the client subscription to get set up + time.Sleep(100 * time.Millisecond) + // make the tx _, _, tx := MakeTxKV() evtTyp := types.EventTx