From be144da09996c27d5cda6a3e032f0287423da3aa Mon Sep 17 00:00:00 2001 From: Potuz Date: Wed, 1 Oct 2025 16:29:20 -0300 Subject: [PATCH] fix test race conditions (#15792) Fix race condition where svc.verifierWaiter was being set after svc.Start() was already running, causing nil pointer dereference. --- beacon-chain/sync/validate_bls_to_execution_change_test.go | 2 +- beacon-chain/sync/validate_sync_committee_message_test.go | 2 +- changelog/potuz_fix_races_in_tests.md | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog/potuz_fix_races_in_tests.md diff --git a/beacon-chain/sync/validate_bls_to_execution_change_test.go b/beacon-chain/sync/validate_bls_to_execution_change_test.go index 4df71e4d2c..8fc1a06819 100644 --- a/beacon-chain/sync/validate_bls_to_execution_change_test.go +++ b/beacon-chain/sync/validate_bls_to_execution_change_test.go @@ -429,12 +429,12 @@ func TestService_ValidateBlsToExecutionChange(t *testing.T) { svc := NewService(ctx, append(opts, tt.svcopts...)...) markInitSyncComplete(t, svc) svc, tt.args.topic = tt.setupSvc(svc, tt.args.msg, tt.args.topic) - go svc.Start() if tt.clock == nil { tt.clock = startup.NewClock(time.Now(), [32]byte{}) } require.NoError(t, cw.SetClock(tt.clock)) svc.verifierWaiter = verification.NewInitializerWaiter(cw, chainService.ForkChoiceStore, svc.cfg.stateGen) + go svc.Start() marshalledObj, err := tt.args.msg.MarshalSSZ() assert.NoError(t, err) diff --git a/beacon-chain/sync/validate_sync_committee_message_test.go b/beacon-chain/sync/validate_sync_committee_message_test.go index f5e4c4d810..bd59adae18 100644 --- a/beacon-chain/sync/validate_sync_committee_message_test.go +++ b/beacon-chain/sync/validate_sync_committee_message_test.go @@ -410,9 +410,9 @@ func TestService_ValidateSyncCommitteeMessage(t *testing.T) { var clock *startup.Clock svc, tt.args.topic, clock = tt.setupSvc(svc, tt.args.msg, tt.args.topic) markInitSyncComplete(t, svc) - go svc.Start() require.NoError(t, cw.SetClock(clock)) svc.verifierWaiter = verification.NewInitializerWaiter(cw, chainService.ForkChoiceStore, svc.cfg.stateGen) + go svc.Start() marshalledObj, err := tt.args.msg.MarshalSSZ() assert.NoError(t, err) diff --git a/changelog/potuz_fix_races_in_tests.md b/changelog/potuz_fix_races_in_tests.md new file mode 100644 index 0000000000..4f143e791b --- /dev/null +++ b/changelog/potuz_fix_races_in_tests.md @@ -0,0 +1,3 @@ +### Ignored + +- Fix races in tests that cause nil panics.