Skip to content

Commit

Permalink
fix(beacon-chain/rpc): correct block root for block events (#11666)
Browse files Browse the repository at this point in the history
  • Loading branch information
Savid authored Nov 22, 2022
1 parent 9761bd0 commit fe1281d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion beacon-chain/rpc/eth/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func handleBlockEvents(
if err != nil {
return err
}
item, err := v1Data.HashTreeRoot()
item, err := v1Data.Message.HashTreeRoot()
if err != nil {
return errors.Wrap(err, "could not hash tree root block")
}
Expand Down
12 changes: 9 additions & 3 deletions beacon-chain/rpc/eth/events/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@ func TestStreamEvents_BlockEvents(t *testing.T) {
srv, ctrl, mockStream := setupServer(ctx, t)
defer ctrl.Finish()

wantedBlock := util.HydrateSignedBeaconBlock(&eth.SignedBeaconBlock{
blk := util.HydrateSignedBeaconBlock(&eth.SignedBeaconBlock{
Block: &eth.BeaconBlock{
Slot: 8,
},
})
wantedBlockRoot, err := wantedBlock.HashTreeRoot()
bodyRoot, err := blk.Block.Body.HashTreeRoot()
require.NoError(t, err)
wantedHeader := util.HydrateBeaconHeader(&eth.BeaconBlockHeader{
Slot: 8,
BodyRoot: bodyRoot[:],
})
wantedBlockRoot, err := wantedHeader.HashTreeRoot()
require.NoError(t, err)
genericResponse, err := anypb.New(&ethpb.EventBlock{
Slot: 8,
Expand All @@ -66,7 +72,7 @@ func TestStreamEvents_BlockEvents(t *testing.T) {
Event: BlockTopic,
Data: genericResponse,
}
wsb, err := blocks.NewSignedBeaconBlock(wantedBlock)
wsb, err := blocks.NewSignedBeaconBlock(blk)
require.NoError(t, err)
assertFeedSendAndReceive(ctx, &assertFeedArgs{
t: t,
Expand Down

0 comments on commit fe1281d

Please sign in to comment.