Skip to content

Commit

Permalink
fix: return events from preblocker in FinalizeBlockResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
facundomedica committed Aug 2, 2024
1 parent c55e8d7 commit c6963cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Finaliz
if err := app.preBlock(req); err != nil {
return nil, err
}
events = append(events, app.finalizeBlockState.ctx.EventManager().ABCIEvents()...)

beginBlock, err := app.beginBlock(req)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2298,13 +2298,16 @@ func TestBaseApp_PreBlocker(t *testing.T) {
wasHookCalled := false
app.SetPreBlocker(func(ctx sdk.Context, req *abci.FinalizeBlockRequest) error {
wasHookCalled = true
ctx.EventManager().EmitEvent(sdk.NewEvent("preblockertest", sdk.NewAttribute("height", fmt.Sprintf("%d", req.Height))))
return nil
})
app.Seal()

_, err = app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1})
res, err := app.FinalizeBlock(&abci.FinalizeBlockRequest{Height: 1})
require.NoError(t, err)
require.Equal(t, true, wasHookCalled)
require.Len(t, res.Events, 1)
require.Equal(t, "preblockertest", res.Events[0].Type)

// Now try erroring
app = baseapp.NewBaseApp(name, logger, db, nil)
Expand Down

0 comments on commit c6963cd

Please sign in to comment.