diff --git a/client/internal/peer/status_test.go b/client/internal/peer/status_test.go index 4d7a4ca78..33ea4ee0b 100644 --- a/client/internal/peer/status_test.go +++ b/client/internal/peer/status_test.go @@ -1,6 +1,7 @@ package peer import ( + "context" "errors" "sync" "testing" @@ -99,10 +100,12 @@ func TestGetPeerStateChangeNotifierLogic(t *testing.T) { err := status.UpdatePeerRelayedStateToDisconnected(peerState) assert.NoError(t, err, "shouldn't return error") + timeoutCtx, cancel := context.WithTimeout(context.Background(), 1*time.Second) + defer cancel() select { case <-sub.eventsChan: - default: - t.Errorf("channel wasn't closed after update") + case <-timeoutCtx.Done(): + t.Errorf("timed out waiting for event") } }