mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 16:08:26 -05:00
feat(rpc/validator): stream and use deneb block (#12510)
This commit is contained in:
committed by
Preston Van Loon
parent
5b1634b335
commit
2be87f623b
@@ -349,6 +349,8 @@ func (v *validator) ReceiveBlocks(ctx context.Context, connectionErrorChannel ch
|
||||
blk, err = blocks.NewSignedBeaconBlock(b.BellatrixBlock)
|
||||
case *ethpb.StreamBlocksResponse_CapellaBlock:
|
||||
blk, err = blocks.NewSignedBeaconBlock(b.CapellaBlock)
|
||||
case *ethpb.StreamBlocksResponse_DenebBlock:
|
||||
blk, err = blocks.NewSignedBeaconBlock(b.DenebBlock)
|
||||
}
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to wrap signed block")
|
||||
|
||||
@@ -949,6 +949,37 @@ func TestService_ReceiveBlocks_SetHighest(t *testing.T) {
|
||||
require.Equal(t, slot, v.highestValidSlot)
|
||||
}
|
||||
|
||||
func TestService_ReceiveBlocks_SetHighestDeneb(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
client := validatormock.NewMockValidatorClient(ctrl)
|
||||
|
||||
v := validator{
|
||||
validatorClient: client,
|
||||
blockFeed: new(event.Feed),
|
||||
}
|
||||
stream := mock2.NewMockBeaconNodeValidatorAltair_StreamBlocksClient(ctrl)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
client.EXPECT().StreamBlocksAltair(
|
||||
gomock.Any(),
|
||||
ðpb.StreamBlocksRequest{VerifiedOnly: true},
|
||||
).Return(stream, nil)
|
||||
stream.EXPECT().Context().Return(ctx).AnyTimes()
|
||||
slot := primitives.Slot(100)
|
||||
stream.EXPECT().Recv().Return(
|
||||
ðpb.StreamBlocksResponse{
|
||||
Block: ðpb.StreamBlocksResponse_DenebBlock{
|
||||
DenebBlock: ðpb.SignedBeaconBlockDeneb{Block: ðpb.BeaconBlockDeneb{Slot: slot, Body: ðpb.BeaconBlockBodyDeneb{}}}},
|
||||
},
|
||||
nil,
|
||||
).Do(func() {
|
||||
cancel()
|
||||
})
|
||||
connectionErrorChannel := make(chan error)
|
||||
v.ReceiveBlocks(ctx, connectionErrorChannel)
|
||||
require.Equal(t, slot, v.highestValidSlot)
|
||||
}
|
||||
|
||||
type doppelGangerRequestMatcher struct {
|
||||
req *ethpb.DoppelGangerRequest
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user