mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
fix test race conditions (#15792)
Fix race condition where svc.verifierWaiter was being set after svc.Start() was already running, causing nil pointer dereference.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
3
changelog/potuz_fix_races_in_tests.md
Normal file
3
changelog/potuz_fix_races_in_tests.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Ignored
|
||||
|
||||
- Fix races in tests that cause nil panics.
|
||||
Reference in New Issue
Block a user