@@ -397,9 +397,8 @@ func TestWaitForActivation_RemoteKeymanager(t *testing.T) {
397
397
398
398
inactiveKey := bytesutil .ToBytes48 ([]byte ("inactive" ))
399
399
activeKey := bytesutil .ToBytes48 ([]byte ("active" ))
400
- km := & remote.MockKeymanager {
401
- PublicKeys : [][48 ]byte {inactiveKey , activeKey },
402
- }
400
+ km := remote .NewMock ()
401
+ km .PublicKeys = [][48 ]byte {inactiveKey , activeKey }
403
402
slot := types .Slot (0 )
404
403
405
404
t .Run ("activated" , func (t * testing.T ) {
@@ -412,7 +411,7 @@ func TestWaitForActivation_RemoteKeymanager(t *testing.T) {
412
411
}
413
412
v := validator {
414
413
validatorClient : client ,
415
- keyManager : km ,
414
+ keyManager : & km ,
416
415
ticker : ticker ,
417
416
}
418
417
go func () {
@@ -447,7 +446,7 @@ func TestWaitForActivation_RemoteKeymanager(t *testing.T) {
447
446
}
448
447
v := validator {
449
448
validatorClient : client ,
450
- keyManager : km ,
449
+ keyManager : & km ,
451
450
ticker : ticker ,
452
451
}
453
452
go func () {
@@ -458,4 +457,52 @@ func TestWaitForActivation_RemoteKeymanager(t *testing.T) {
458
457
err := v .waitForActivation (ctx , nil /* accountsChangedChan */ )
459
458
assert .ErrorContains (t , "context canceled, not waiting for activation anymore" , err )
460
459
})
460
+ t .Run ("reloaded" , func (t * testing.T ) {
461
+ ctx , cancel := context .WithCancel (context .Background ())
462
+ hook := logTest .NewGlobal ()
463
+ remoteKm := remote .NewMock ()
464
+ remoteKm .PublicKeys = [][48 ]byte {inactiveKey }
465
+
466
+ tickerChan := make (chan types.Slot )
467
+ ticker := & slotutilmock.MockTicker {
468
+ Channel : tickerChan ,
469
+ }
470
+ v := validator {
471
+ validatorClient : client ,
472
+ keyManager : & remoteKm ,
473
+ ticker : ticker ,
474
+ }
475
+ go func () {
476
+ tickerChan <- slot
477
+ time .Sleep (time .Second )
478
+ remoteKm .PublicKeys = [][48 ]byte {inactiveKey , activeKey }
479
+ tickerChan <- slot
480
+ // Cancel after timeout to avoid waiting on channel forever in case test goes wrong.
481
+ time .Sleep (time .Second )
482
+ cancel ()
483
+ }()
484
+
485
+ resp := testutil .GenerateMultipleValidatorStatusResponse ([][]byte {inactiveKey [:]})
486
+ resp .Statuses [0 ].Status = ethpb .ValidatorStatus_UNKNOWN_STATUS
487
+ client .EXPECT ().MultipleValidatorStatus (
488
+ gomock .Any (),
489
+ & ethpb.MultipleValidatorStatusRequest {
490
+ PublicKeys : [][]byte {inactiveKey [:]},
491
+ },
492
+ ).Return (resp , nil /* err */ )
493
+ resp2 := testutil .GenerateMultipleValidatorStatusResponse ([][]byte {inactiveKey [:], activeKey [:]})
494
+ resp2 .Statuses [0 ].Status = ethpb .ValidatorStatus_UNKNOWN_STATUS
495
+ resp2 .Statuses [1 ].Status = ethpb .ValidatorStatus_ACTIVE
496
+ client .EXPECT ().MultipleValidatorStatus (
497
+ gomock .Any (),
498
+ & ethpb.MultipleValidatorStatusRequest {
499
+ PublicKeys : [][]byte {inactiveKey [:], activeKey [:]},
500
+ },
501
+ ).Return (resp2 , nil /* err */ )
502
+
503
+ err := v .waitForActivation (ctx , remoteKm .ReloadPublicKeysChan /* accountsChangedChan */ )
504
+ require .NoError (t , err )
505
+ assert .LogsContain (t , hook , "Waiting for deposit to be observed by beacon node" )
506
+ assert .LogsContain (t , hook , "Validator activated" )
507
+ })
461
508
}
0 commit comments