diff --git a/.github/workflows/relay.yml b/.github/workflows/relay.yml index b6592aad3..f5295032d 100644 --- a/.github/workflows/relay.yml +++ b/.github/workflows/relay.yml @@ -19,6 +19,8 @@ jobs: run: go build -v ./pkg/... - name: Test run: go test ./pkg/... -v + - name: Test with the race detector enabled + run: go test ./pkg/... -v -race -count=10 lint: runs-on: ubuntu-latest diff --git a/pkg/monitoring/multi_feed_monitor_test.go b/pkg/monitoring/multi_feed_monitor_test.go index 96ad9633c..410710b74 100644 --- a/pkg/monitoring/multi_feed_monitor_test.go +++ b/pkg/monitoring/multi_feed_monitor_test.go @@ -3,6 +3,7 @@ package monitoring import ( "context" "sync" + "sync/atomic" "testing" "time" @@ -121,7 +122,7 @@ func TestMultiFeedMonitorForPerformance(t *testing.T) { ) go monitor.Start(ctx, wg) - trCount, stCount := 0, 0 + var trCount, stCount int64 = 0, 0 messages := []producerMessage{} wg.Add(1) @@ -133,9 +134,9 @@ func TestMultiFeedMonitorForPerformance(t *testing.T) { require.NoError(t, err) select { case transmissionReader.readCh <- generateTransmissionEnvelope(): - trCount += 1 + _ = atomic.AddInt64(&trCount, 1) case stateReader.readCh <- StateEnvelope{newState, 100}: - stCount += 1 + _ = atomic.AddInt64(&stCount, 1) case <-ctx.Done(): break LOOP } @@ -156,7 +157,7 @@ func TestMultiFeedMonitorForPerformance(t *testing.T) { }() wg.Wait() - require.Equal(t, 10, trCount, "should only be able to do initial read of the latest transmission") - require.Equal(t, 10, stCount, "should only be able to do initial read of the state account") + require.Equal(t, int64(10), trCount, "should only be able to do initial read of the latest transmission") + require.Equal(t, int64(10), stCount, "should only be able to do initial read of the state account") require.Equal(t, 30, len(messages)) }