laconicd-deprecated/x/feemarket/keeper/abci_test.go
Daniel Burckhardt 93020f8786
feemarket: unit tests EIP1559 (#758)
* Fee-Market(Types): Setup Params tests

* Fee-Market(Types): Add all Params tests

* Fee-Market(Types): Add genesis tests

* Fee-Market(Keeper): Copy Keeper setup from EVM module and add Params tests

* Fee-Market(Keeper): Add Keeper tests

* Fee-Market(Keeper): Add review comments

* Fee-Market(Keeper): WIP grpc tests

* Fee-Market(Keeper): WIP ERIP1559 tests

* Fee-Market(Keeper): WIP ERIP1559 tests

* Fee-Market(Keeper): WIP ERIP1559 tests maxGas influences on baseFee

* Fee-Market(Keeper): Add last ERIP1559 tests

* Fee-Market(Keeper): Add abci tests
2021-11-19 16:22:25 +00:00

56 lines
1.2 KiB
Go

package keeper_test
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
abci "github.com/tendermint/tendermint/abci/types"
)
func (suite *KeeperTestSuite) TestEndBlock() {
testCases := []struct {
name string
NoBaseFee bool
malleate func()
expGasUsed uint64
}{
{
"basFee nil",
true,
func() {},
uint64(0),
},
{
"Block gas meter is nil",
false,
func() {},
uint64(0),
},
{
"pass",
false,
func() {
meter := sdk.NewGasMeter(uint64(1000000000))
suite.ctx = suite.ctx.WithBlockGasMeter(meter)
suite.ctx.BlockGasMeter().ConsumeGas(uint64(5000000), "consume gas")
},
uint64(5000000),
},
}
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()
req := abci.RequestEndBlock{Height: 1}
suite.app.FeeMarketKeeper.EndBlock(suite.ctx, req)
gasUsed := suite.app.FeeMarketKeeper.GetBlockGasUsed(suite.ctx)
suite.Require().Equal(tc.expGasUsed, gasUsed, tc.name)
})
}
}