Co-authored-by: mmsqe <mavis@crypto.com> Co-authored-by: aljo242 <alex@interchainlabs.io>
This commit is contained in:
co-authored by
mmsqe
aljo242
parent
8903e43a9e
commit
b0ee102cfa
@@ -855,6 +855,9 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Request
|
||||
// where they adhere to the sdk.Tx interface.
|
||||
func (app *BaseApp) FinalizeBlock(req *abci.RequestFinalizeBlock) (res *abci.ResponseFinalizeBlock, err error) {
|
||||
defer func() {
|
||||
if res == nil {
|
||||
return
|
||||
}
|
||||
// call the streaming service hooks with the FinalizeBlock messages
|
||||
for _, streamingListener := range app.streamingManager.ABCIListeners {
|
||||
if err := streamingListener.ListenFinalizeBlock(app.finalizeBlockState.Context(), *req, *res); err != nil {
|
||||
|
||||
@@ -43,6 +43,18 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
)
|
||||
|
||||
type mockABCIListener struct {
|
||||
ListenCommitFn func(context.Context, abci.ResponseCommit, []*storetypes.StoreKVPair) error
|
||||
}
|
||||
|
||||
func (m mockABCIListener) ListenFinalizeBlock(_ context.Context, _ abci.RequestFinalizeBlock, _ abci.ResponseFinalizeBlock) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockABCIListener) ListenCommit(ctx context.Context, commit abci.ResponseCommit, pairs []*storetypes.StoreKVPair) error {
|
||||
return m.ListenCommitFn(ctx, commit, pairs)
|
||||
}
|
||||
|
||||
func TestABCI_Info(t *testing.T) {
|
||||
suite := NewBaseAppSuite(t)
|
||||
|
||||
@@ -2493,3 +2505,18 @@ func TestABCI_Proposal_FailReCheckTx(t *testing.T) {
|
||||
require.NotEmpty(t, res.TxResults[0].Events)
|
||||
require.True(t, res.TxResults[0].IsOK(), fmt.Sprintf("%v", res))
|
||||
}
|
||||
|
||||
func TestFinalizeBlockDeferResponseHandle(t *testing.T) {
|
||||
suite := NewBaseAppSuite(t, baseapp.SetHaltHeight(1))
|
||||
suite.baseApp.SetStreamingManager(storetypes.StreamingManager{
|
||||
ABCIListeners: []storetypes.ABCIListener{
|
||||
&mockABCIListener{},
|
||||
},
|
||||
})
|
||||
|
||||
res, err := suite.baseApp.FinalizeBlock(&abci.RequestFinalizeBlock{
|
||||
Height: 2,
|
||||
})
|
||||
require.Empty(t, res)
|
||||
require.NotEmpty(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user