Skip to content

Commit

Permalink
Add tests to cover consensus parameter updates
Browse files Browse the repository at this point in the history
  • Loading branch information
0Tech committed Sep 21, 2022
1 parent f9f9e11 commit fd0be15
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,39 @@ func TestBaseAppCreateQueryContext(t *testing.T) {
})
}
}

// Test and ensure that consensus params has been updated.
// See:
// - https://github.com/line/lbm-sdk/pull/673
func TestBaseAppBeginBlockConsensusParams(t *testing.T) {
t.Parallel()

logger := defaultLogger()
db := dbm.NewMemDB()
name := t.Name()
app := NewBaseApp(name, logger, db, nil)
app.SetParamStore(&paramStore{db: dbm.NewMemDB()})
app.InitChain(abci.RequestInitChain{
ConsensusParams: &abci.ConsensusParams{
Block: &abci.BlockParams{
MaxGas: -1,
},
},
})
app.init()

// set block params
app.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{Height: 1}})
ctx := app.deliverState.ctx
maxGas := int64(123456789)
app.paramStore.Set(ctx, ParamStoreKeyBlockParams,
&abci.BlockParams{
MaxGas: maxGas,
})
app.Commit()

// confirm consensus params updated into the context
app.BeginBlock(abci.RequestBeginBlock{Header: ocproto.Header{Height: 2}})
newCtx := app.getContextForTx(app.checkState, []byte{})
require.Equal(t, maxGas, newCtx.ConsensusParams().Block.MaxGas)
}

0 comments on commit fd0be15

Please sign in to comment.