fix: remove setting of finalizeBlockState in FinalizeBlock + fix initialHeight + add ProcessProposal in tests/sims (#16794)

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
Facundo Medica
2023-07-06 13:33:10 +00:00
committed by GitHub
co-authored by Aleksandr Bezobchuk
parent 101992aa7a
commit 0fd6227a06
19 changed files with 206 additions and 66 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ func Example_oneModule() {
Params: params,
},
// this allows to the begin and end blocker of the module before and after the message
integration.WithAutomaticFinalizeBlock(),
integration.WithAutomaticProcessProposal(),
// this allows to commit the state after the message
integration.WithAutomaticCommit(),
)
+10 -2
View File
@@ -2,13 +2,21 @@ package integration
// Config is the configuration for the integration app.
type Config struct {
AutomaticFinalizeBlock bool
AutomaticCommit bool
AutomaticProcessProposal bool
AutomaticFinalizeBlock bool
AutomaticCommit bool
}
// Option is a function that can be used to configure the integration app.
type Option func(*Config)
// WithAutomaticProcessProposal calls ABCI process proposal.
func WithAutomaticProcessProposal() Option {
return func(cfg *Config) {
cfg.AutomaticProcessProposal = true
}
}
// WithAutomaticFinalizeBlock calls ABCI finalize block.
func WithAutomaticFinalizeBlock() Option {
return func(cfg *Config) {
+7
View File
@@ -132,6 +132,13 @@ func (app *App) RunMsg(msg sdk.Msg, option ...Option) (*codectypes.Any, error) {
defer app.Commit()
}
if cfg.AutomaticProcessProposal {
height := app.LastBlockHeight() + 1
if _, err := app.ProcessProposal(&cmtabcitypes.RequestProcessProposal{Height: height}); err != nil {
return nil, fmt.Errorf("failed to run process proposal: %w", err)
}
}
if cfg.AutomaticFinalizeBlock {
height := app.LastBlockHeight() + 1
if _, err := app.FinalizeBlock(&cmtabcitypes.RequestFinalizeBlock{Height: height}); err != nil {
+2 -1
View File
@@ -141,7 +141,8 @@ func SignCheckDeliver(
require.False(t, finalizeSuccess)
}
app.Commit()
_, err = app.Commit()
require.NoError(t, err)
gInfo := sdk.GasInfo{GasWanted: uint64(txResult.GasWanted), GasUsed: uint64(txResult.GasUsed)}
txRes := sdk.Result{Data: txResult.Data, Log: txResult.Log, Events: txResult.Events}