Send Consensus Params during EndBlock (#7107)
* add cp to endblock * fix build * add test: TestBaseApp_EndBlock Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
16435a0f4d
commit
049731bb3c
|
@ -163,7 +163,11 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc
|
|||
res = app.endBlocker(app.deliverState.ctx, req)
|
||||
}
|
||||
|
||||
return
|
||||
if cp := app.GetConsensusParams(app.deliverState.ctx); cp != nil {
|
||||
res.ConsensusParamUpdates = cp
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// CheckTx implements the ABCI interface and executes a tx in CheckTx mode. In
|
||||
|
|
|
@ -1678,3 +1678,35 @@ func TestWithRouter(t *testing.T) {
|
|||
app.Commit()
|
||||
}
|
||||
}
|
||||
|
||||
func TestBaseApp_EndBlock(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
name := t.Name()
|
||||
logger := defaultLogger()
|
||||
|
||||
cp := &abci.ConsensusParams{
|
||||
Block: &abci.BlockParams{
|
||||
MaxGas: 5000000,
|
||||
},
|
||||
}
|
||||
|
||||
app := NewBaseApp(name, logger, db, nil)
|
||||
app.SetParamStore(¶mStore{db: dbm.NewMemDB()})
|
||||
app.InitChain(abci.RequestInitChain{
|
||||
ConsensusParams: cp,
|
||||
})
|
||||
|
||||
app.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
|
||||
return abci.ResponseEndBlock{
|
||||
ValidatorUpdates: []abci.ValidatorUpdate{
|
||||
{Power: 100},
|
||||
},
|
||||
}
|
||||
})
|
||||
app.Seal()
|
||||
|
||||
res := app.EndBlock(abci.RequestEndBlock{})
|
||||
require.Len(t, res.GetValidatorUpdates(), 1)
|
||||
require.Equal(t, int64(100), res.GetValidatorUpdates()[0].Power)
|
||||
require.Equal(t, cp.Block.MaxGas, res.ConsensusParamUpdates.Block.MaxGas)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue