events: Add block_id to NewBlockEvent (#6478)

Adds `block_id` to the `newblock` websocket event

Closes #6028
This commit is contained in:
Greg Morrison
2021-05-27 07:43:24 +00:00
committed by GitHub
parent 11b5885894
commit 692f23d589
4 changed files with 11 additions and 3 deletions
+3
View File
@@ -75,6 +75,7 @@ func TestEventBusPublishEventNewBlock(t *testing.T) {
})
block := MakeBlock(0, []Tx{}, nil, []Evidence{})
blockID := BlockID{Hash: block.Hash(), PartSetHeader: block.MakePartSet(BlockPartSizeBytes).Header()}
resultBeginBlock := abci.ResponseBeginBlock{
Events: []abci.Event{
{Type: "testType", Attributes: []abci.EventAttribute{{Key: "baz", Value: "1"}}},
@@ -96,6 +97,7 @@ func TestEventBusPublishEventNewBlock(t *testing.T) {
msg := <-blocksSub.Out()
edt := msg.Data().(EventDataNewBlock)
assert.Equal(t, block, edt.Block)
assert.Equal(t, blockID, edt.BlockID)
assert.Equal(t, resultBeginBlock, edt.ResultBeginBlock)
assert.Equal(t, resultEndBlock, edt.ResultEndBlock)
close(done)
@@ -103,6 +105,7 @@ func TestEventBusPublishEventNewBlock(t *testing.T) {
err = eventBus.PublishEventNewBlock(EventDataNewBlock{
Block: block,
BlockID: blockID,
ResultBeginBlock: resultBeginBlock,
ResultEndBlock: resultEndBlock,
})
+2 -1
View File
@@ -62,7 +62,8 @@ func init() {
// but some (an input to a call tx or a receive) are more exotic
type EventDataNewBlock struct {
Block *Block `json:"block"`
Block *Block `json:"block"`
BlockID BlockID `json:"block_id"`
ResultBeginBlock abci.ResponseBeginBlock `json:"result_begin_block"`
ResultEndBlock abci.ResponseEndBlock `json:"result_end_block"`