mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-12 12:40:05 +00:00
Fix GetValidatorParticipation
slot to epoch conversion (#7721)
* Fix current slot conversion * Update tests * Use a higher epoch number
This commit is contained in:
parent
b996824446
commit
f1e6aba34e
@ -469,7 +469,7 @@ func (bs *Server) GetValidatorActiveSetChanges(
|
||||
func (bs *Server) GetValidatorParticipation(
|
||||
ctx context.Context, req *ethpb.GetValidatorParticipationRequest,
|
||||
) (*ethpb.ValidatorParticipationResponse, error) {
|
||||
currentSlot := helpers.SlotToEpoch(bs.GenesisTimeFetcher.CurrentSlot())
|
||||
currentSlot := bs.GenesisTimeFetcher.CurrentSlot()
|
||||
currentEpoch := helpers.SlotToEpoch(currentSlot)
|
||||
|
||||
var requestedEpoch uint64
|
||||
|
@ -1409,6 +1409,37 @@ func TestServer_GetValidatorParticipation_CannotRequestFutureEpoch(t *testing.T)
|
||||
assert.ErrorContains(t, wanted, err)
|
||||
}
|
||||
|
||||
func TestServer_GetValidatorParticipation_UnknownState(t *testing.T) {
|
||||
db, _ := dbTest.SetupDB(t)
|
||||
|
||||
ctx := context.Background()
|
||||
headState := testutil.NewBeaconState()
|
||||
require.NoError(t, headState.SetSlot(0))
|
||||
epoch := uint64(50)
|
||||
slots := epoch * params.BeaconConfig().SlotsPerEpoch
|
||||
bs := &Server{
|
||||
BeaconDB: db,
|
||||
HeadFetcher: &mock.ChainService{
|
||||
State: headState,
|
||||
},
|
||||
GenesisTimeFetcher: &mock.ChainService{
|
||||
Genesis: time.Now().Add(time.Duration(-1*int64(slots)) * time.Second),
|
||||
},
|
||||
StateGen: stategen.New(db, cache.NewStateSummaryCache()),
|
||||
}
|
||||
|
||||
wanted := "Could not get state: unknown state"
|
||||
_, err := bs.GetValidatorParticipation(
|
||||
ctx,
|
||||
ðpb.GetValidatorParticipationRequest{
|
||||
QueryFilter: ðpb.GetValidatorParticipationRequest_Epoch{
|
||||
Epoch: 1,
|
||||
},
|
||||
},
|
||||
)
|
||||
assert.ErrorContains(t, wanted, err)
|
||||
}
|
||||
|
||||
func TestServer_GetValidatorParticipation_CurrentAndPrevEpoch(t *testing.T) {
|
||||
db, sc := dbTest.SetupDB(t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user