fix(mempool parity): Enforce comet / app-side mempool parity in CheckTx + integ. tests [BLO-584] [BLO-635] (#306)

* account setup for network tests

* Add Test case for app-mempool / cmt mempool parity

* add fix

* move check-tx handlers to wrap each other

* linting

* migrate to chaintestutils

* linting

* additional test-case

* lint

* remove paralell tests

* remove MEVLaneI

* fix(check_tx): Check error of GetAuctionBid in ValidateBidTx [BLO-461] (#312)

* add err check in ValidateBidTx

* add test-case for ValidateBidTx

* remove -race flag for integ
This commit is contained in:
Nikhil Vasan
2023-12-18 18:29:06 -08:00
committed by GitHub
parent 4b6e481c3f
commit b5fe2a772c
16 changed files with 1196 additions and 406 deletions
+65 -7
View File
@@ -6,12 +6,6 @@ import (
"os"
"cosmossdk.io/log"
pruningtypes "cosmossdk.io/store/pruning/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"cosmossdk.io/math"
"github.com/cosmos/gogoproto/proto"
"github.com/skip-mev/chaintestutil/network"
@@ -19,6 +13,18 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
pruningtypes "cosmossdk.io/store/pruning/types"
cmtrand "github.com/cometbft/cometbft/libs/rand"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/baseapp"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/skip-mev/chaintestutil/account"
"github.com/skip-mev/block-sdk/lanes/base"
"github.com/skip-mev/block-sdk/lanes/free"
"github.com/skip-mev/block-sdk/lanes/mev"
@@ -27,13 +33,22 @@ import (
blocksdktypes "github.com/skip-mev/block-sdk/x/blocksdk/types"
)
// NetworkTestSuite is a test suite for tests that initializes a network instance.
var (
chainID = "chain-" + cmtrand.NewRand().Str(6)
genBalance = sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1000000000000000000))
)
// NetworkTestSuite is a test suite for query tests that initializes a network instance.
type NetworkTestSuite struct {
suite.Suite
NetworkSuite *network.TestSuite
AuctionState auctiontypes.GenesisState
BlockSDKState blocksdktypes.GenesisState
AuthState authtypes.GenesisState
BankState banktypes.GenesisState
Accounts []*account.Account
}
// SetupSuite setups the local network with a genesis state.
@@ -55,6 +70,7 @@ func (nts *NetworkTestSuite) SetupSuite() {
}
)
cfg.AppConstructor = appCons
cfg.ChainID = chainID
updateGenesisConfigState := func(moduleName string, moduleState proto.Message) {
buf, err := cfg.Codec.MarshalJSON(moduleState)
@@ -70,9 +86,51 @@ func (nts *NetworkTestSuite) SetupSuite() {
nts.BlockSDKState = populateBlockSDK(r, nts.BlockSDKState)
updateGenesisConfigState(blocksdktypes.ModuleName, &nts.BlockSDKState)
// add genesis accounts
nts.Accounts = []*account.Account{
account.NewAccount(),
}
require.NoError(nts.T(), cfg.Codec.UnmarshalJSON(cfg.GenesisState[authtypes.ModuleName], &nts.AuthState))
require.NoError(nts.T(), cfg.Codec.UnmarshalJSON(cfg.GenesisState[banktypes.ModuleName], &nts.BankState))
addGenesisAccounts(&nts.AuthState, &nts.BankState, nts.Accounts)
// update genesis
updateGenesisConfigState(authtypes.ModuleName, &nts.AuthState)
updateGenesisConfigState(banktypes.ModuleName, &nts.BankState)
nts.NetworkSuite = network.NewSuite(nts.T(), cfg)
}
// addGenesisAccount adds a genesis account to the auth / bank genesis state.
func addGenesisAccounts(authGenState *authtypes.GenesisState, bankGenState *banktypes.GenesisState, accs []*account.Account) {
balances := make([]banktypes.Balance, len(accs))
accounts := make(authtypes.GenesisAccounts, len(accs))
// create accounts / update bank state w/ account + gen balance
for i, acc := range accs {
// base account
bacc := authtypes.NewBaseAccount(acc.Address(), acc.PubKey(), 0, 0)
accounts[i] = bacc
balances[i] = banktypes.Balance{
Address: acc.Address().String(),
Coins: sdk.NewCoins(genBalance),
}
}
// update auth state w/ accounts
var err error
authGenState.Accounts, err = authtypes.PackAccounts(accounts)
if err != nil {
panic(err)
}
// update bank state w/ balances
bankGenState.Balances = balances
}
func populateAuction(_ *rand.Rand, auctionState auctiontypes.GenesisState) auctiontypes.GenesisState {
// TODO intercept and populate state randomly if desired
return auctionState