2021-11-19 16:22:25 +00:00
|
|
|
package keeper_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2022-10-10 10:38:33 +00:00
|
|
|
"github.com/tendermint/tendermint/abci/types"
|
2021-11-19 16:22:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (suite *KeeperTestSuite) TestEndBlock() {
|
|
|
|
testCases := []struct {
|
2022-10-10 10:38:33 +00:00
|
|
|
name string
|
|
|
|
NoBaseFee bool
|
|
|
|
malleate func()
|
|
|
|
expGasWanted uint64
|
2021-11-19 16:22:25 +00:00
|
|
|
}{
|
|
|
|
{
|
2022-10-10 10:38:33 +00:00
|
|
|
"baseFee nil",
|
2021-11-19 16:22:25 +00:00
|
|
|
true,
|
|
|
|
func() {},
|
|
|
|
uint64(0),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"pass",
|
|
|
|
false,
|
|
|
|
func() {
|
|
|
|
meter := sdk.NewGasMeter(uint64(1000000000))
|
|
|
|
suite.ctx = suite.ctx.WithBlockGasMeter(meter)
|
2022-10-10 10:38:33 +00:00
|
|
|
suite.app.FeeMarketKeeper.SetTransientBlockGasWanted(suite.ctx, 5000000)
|
2021-11-19 16:22:25 +00:00
|
|
|
},
|
2022-10-10 10:38:33 +00:00
|
|
|
uint64(2500000),
|
2021-11-19 16:22:25 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
|
|
suite.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
|
|
|
suite.SetupTest() // reset
|
|
|
|
params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
|
|
|
|
params.NoBaseFee = tc.NoBaseFee
|
|
|
|
suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
|
|
|
|
|
|
|
|
tc.malleate()
|
2022-10-10 10:38:33 +00:00
|
|
|
suite.app.FeeMarketKeeper.EndBlock(suite.ctx, types.RequestEndBlock{Height: 1})
|
|
|
|
gasWanted := suite.app.FeeMarketKeeper.GetBlockGasWanted(suite.ctx)
|
|
|
|
suite.Require().Equal(tc.expGasWanted, gasWanted, tc.name)
|
2021-11-19 16:22:25 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|