laconicd/app/test_helpers.go
JayT106 1076307e6b
tests: DynamicFeeTx (#649)
* test DynamicFeeTx against state_transition_benchmark_test

* add feemarketGenesis in the app setup param

* add dynamicTxFee flag to KeeperTestSuite

* add feemarketGenesis.BaseFee setup

* update TestAddLog

* fix gasFeeCap assignment in newMsgEthereumTx

* modify keeperTestSuite helper functions to support dynamicTxFee

* update test cases in grpc_query_test w/ dynamicTxFee

* update the evm keeper utils tests

* add dynamic tx fee in the ante tests

* remove duplicate type define

* fix error return type

* update changelog

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
2021-10-19 08:49:29 +00:00

72 lines
2.0 KiB
Go

package app
import (
"encoding/json"
"time"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/tharsis/ethermint/encoding"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
)
// DefaultConsensusParams defines the default Tendermint consensus params used in
// EthermintApp testing.
var DefaultConsensusParams = &abci.ConsensusParams{
Block: &abci.BlockParams{
MaxBytes: 200000,
MaxGas: -1, // no limit
},
Evidence: &tmproto.EvidenceParams{
MaxAgeNumBlocks: 302400,
MaxAgeDuration: 504 * time.Hour, // 3 weeks is the max duration
MaxBytes: 10000,
},
Validator: &tmproto.ValidatorParams{
PubKeyTypes: []string{
tmtypes.ABCIPubKeyTypeEd25519,
},
},
}
// Setup initializes a new EthermintApp. A Nop logger is set in EthermintApp.
func Setup(isCheckTx bool, feemarketGenesis *feemarkettypes.GenesisState) *EthermintApp {
db := dbm.NewMemDB()
app := NewEthermintApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, encoding.MakeConfig(ModuleBasics), simapp.EmptyAppOptions{})
if !isCheckTx {
// init chain must be called to stop deliverState from being nil
genesisState := NewDefaultGenesisState()
// Verify feeMarket genesis
if feemarketGenesis != nil {
if err := feemarketGenesis.Validate(); err != nil {
panic(err)
}
genesisState[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(feemarketGenesis)
}
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
if err != nil {
panic(err)
}
// Initialize the chain
app.InitChain(
abci.RequestInitChain{
ChainId: "ethermint_9000-1",
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
}
return app
}