Add RPC Changes to Sync For Block Methods (#9497)

* add changes

* radek's review

* kasey's review

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Nishant Das
2021-09-04 00:00:56 +08:00
committed by GitHub
parent e875fe3dfc
commit cc790ceb2e
17 changed files with 325 additions and 86 deletions

View File

@@ -58,6 +58,8 @@ func TestService_InitStartStop(t *testing.T) {
FinalizedCheckPoint: &eth.Checkpoint{
Epoch: 0,
},
Genesis: time.Unix(4113849600, 0),
ValidatorsRoot: [32]byte{},
}
},
methodRuns: func(fd *event.Feed) {
@@ -86,6 +88,8 @@ func TestService_InitStartStop(t *testing.T) {
FinalizedCheckPoint: &eth.Checkpoint{
Epoch: 0,
},
Genesis: time.Now().Add(-5 * time.Minute),
ValidatorsRoot: [32]byte{},
}
},
methodRuns: func(fd *event.Feed) {
@@ -117,6 +121,8 @@ func TestService_InitStartStop(t *testing.T) {
FinalizedCheckPoint: &eth.Checkpoint{
Epoch: helpers.SlotToEpoch(futureSlot),
},
Genesis: makeGenesisTime(futureSlot),
ValidatorsRoot: [32]byte{},
}
},
methodRuns: func(fd *event.Feed) {
@@ -150,7 +156,7 @@ func TestService_InitStartStop(t *testing.T) {
defer hook.Reset()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mc := &mock.ChainService{}
mc := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
// Allow overriding with customized chain service.
if tt.chainService != nil {
mc = tt.chainService()
@@ -211,7 +217,7 @@ func TestService_waitForStateInitialization(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
s := newService(ctx, &mock.ChainService{})
s := newService(ctx, &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}})
wg := &sync.WaitGroup{}
wg.Add(1)
go func() {
@@ -238,7 +244,7 @@ func TestService_waitForStateInitialization(t *testing.T) {
defer hook.Reset()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
s := newService(ctx, &mock.ChainService{})
s := newService(ctx, &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}})
expectedGenesisTime := time.Unix(358544700, 0)
var receivedGenesisTime time.Time
@@ -282,7 +288,7 @@ func TestService_waitForStateInitialization(t *testing.T) {
defer hook.Reset()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
s := newService(ctx, &mock.ChainService{})
s := newService(ctx, &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}})
// Initialize mock feed
_ = s.cfg.StateNotifier.StateFeed()
@@ -320,7 +326,7 @@ func TestService_waitForStateInitialization(t *testing.T) {
}
func TestService_markSynced(t *testing.T) {
mc := &mock.ChainService{}
mc := &mock.ChainService{Genesis: time.Now(), ValidatorsRoot: [32]byte{}}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
s := NewService(ctx, &Config{
@@ -403,6 +409,8 @@ func TestService_Resync(t *testing.T) {
FinalizedCheckPoint: &eth.Checkpoint{
Epoch: helpers.SlotToEpoch(futureSlot),
},
Genesis: time.Now(),
ValidatorsRoot: [32]byte{},
}
},
assert: func(s *Service) {