fix: operation simulation route in x/nft test (#12278)
This commit is contained in:
parent
c68fa3b299
commit
8fa2faba47
@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
* (testutil) [#12278](https:12278//github.com/cosmos/cosmos-sdk/pull/12278) Move all function from `simapp/helpers` to `testutil/sims`
|
||||
* (testutil) [#12233](https://github.com/cosmos/cosmos-sdk/pull/12233) Move `simapp.TestAddr` to `simtestutil.TestAddr` (`testutil/sims`)
|
||||
* (x/staking) [#12102](https://github.com/cosmos/cosmos-sdk/pull/12102) Staking keeper now is passed by reference instead of copy. Keeper's SetHooks no longer returns keeper. It updates the keeper in place instead.
|
||||
* (linting) [#12141](https://github.com/cosmos/cosmos-sdk/pull/12141) Fix usability related linting for database. This means removing the infix Prefix from `prefix.NewPrefixWriter` and such so that it is `prefix.NewWriter` and making `db.DBConnection` and such into `db.Connection`
|
||||
|
||||
@ -18,8 +18,8 @@ import (
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@ -296,7 +296,7 @@ func TestAppStateDeterminism(t *testing.T) {
|
||||
config.ExportParamsPath = ""
|
||||
config.OnOperation = false
|
||||
config.AllInvariants = false
|
||||
config.ChainID = helpers.SimAppChainID
|
||||
config.ChainID = simtestutil.SimAppChainID
|
||||
|
||||
numSeeds := 3
|
||||
numTimesToRunPerSeed := 5
|
||||
|
||||
@ -24,7 +24,6 @@ import (
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/depinject"
|
||||
"github.com/cosmos/cosmos-sdk/server/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/mock"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
@ -275,11 +274,11 @@ func SignCheckDeliver(
|
||||
t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg,
|
||||
chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
|
||||
) (sdk.GasInfo, *sdk.Result, error) {
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txCfg,
|
||||
msgs,
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)},
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
accNums,
|
||||
accSeqs,
|
||||
@ -325,11 +324,11 @@ func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, i
|
||||
txs := make([]sdk.Tx, numToGenerate)
|
||||
var err error
|
||||
for i := 0; i < numToGenerate; i++ {
|
||||
txs[i], err = helpers.GenSignedMockTx(
|
||||
txs[i], err = simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
msgs,
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)},
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
"",
|
||||
accNums,
|
||||
initSeqNums,
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/kv"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
@ -25,7 +25,7 @@ func SetupSimulation(dirPrefix, dbName string) (simtypes.Config, dbm.DB, string,
|
||||
}
|
||||
|
||||
config := NewConfigFromFlags()
|
||||
config.ChainID = helpers.SimAppChainID
|
||||
config.ChainID = simtestutil.SimAppChainID
|
||||
|
||||
var logger log.Logger
|
||||
if FlagVerboseValue {
|
||||
|
||||
@ -26,6 +26,12 @@ import (
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
// SimAppChainID hardcoded chainID for simulation
|
||||
const (
|
||||
DefaultGenTxGas = 10000000
|
||||
SimAppChainID = "simulation-app"
|
||||
)
|
||||
|
||||
// DefaultConsensusParams defines the default Tendermint consensus params used in
|
||||
// SimApp testing.
|
||||
var DefaultConsensusParams = &tmproto.ConsensusParams{
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package helpers
|
||||
package sims
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
@ -12,14 +12,8 @@ import (
|
||||
authsign "github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
)
|
||||
|
||||
// SimAppChainID hardcoded chainID for simulation
|
||||
const (
|
||||
DefaultGenTxGas = 10000000
|
||||
SimAppChainID = "simulation-app"
|
||||
)
|
||||
|
||||
// GenSignedMockTx generates a signed mock transaction.
|
||||
func GenSignedMockTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) {
|
||||
func GenSignedMockTx(txConfig client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) {
|
||||
sigs := make([]signing.SignatureV2, len(priv))
|
||||
|
||||
// create a random length memo
|
||||
@ -27,7 +21,7 @@ func GenSignedMockTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas
|
||||
|
||||
memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100))
|
||||
|
||||
signMode := gen.SignModeHandler().DefaultMode()
|
||||
signMode := txConfig.SignModeHandler().DefaultMode()
|
||||
|
||||
// 1st round: set SignatureV2 with empty signatures, to set correct
|
||||
// signer infos.
|
||||
@ -41,7 +35,7 @@ func GenSignedMockTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas
|
||||
}
|
||||
}
|
||||
|
||||
tx := gen.NewTxBuilder()
|
||||
tx := txConfig.NewTxBuilder()
|
||||
err := tx.SetMsgs(msgs...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -63,7 +57,7 @@ func GenSignedMockTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas
|
||||
Sequence: accSeqs[i],
|
||||
PubKey: p.PubKey(),
|
||||
}
|
||||
signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx())
|
||||
signBytes, err := txConfig.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -11,7 +11,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/testdata"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
@ -144,7 +144,7 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() {
|
||||
accNums, seqs = []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()}
|
||||
}
|
||||
|
||||
tx, err := genTxWithFeeGranter(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, privs...)
|
||||
tx, err := genTxWithFeeGranter(protoTxCfg, msgs, fee, simtestutil.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, privs...)
|
||||
suite.Require().NoError(err)
|
||||
_, err = feeAnteHandler(ctx, tx, false) // tests only feegrant ante
|
||||
if tc.valid {
|
||||
|
||||
@ -7,8 +7,8 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
@ -118,11 +118,11 @@ func SimulateMsgGrant(ak authz.AccountKeeper, bk authz.BankKeeper, _ keeper.Keep
|
||||
return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, err.Error()), nil, err
|
||||
}
|
||||
txCfg := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txCfg,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{granterAcc.GetAccountNumber()},
|
||||
[]uint64{granterAcc.GetSequence()},
|
||||
@ -188,11 +188,11 @@ func SimulateMsgRevoke(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Kee
|
||||
msg := authz.NewMsgRevoke(granterAddr, granteeAddr, a.MsgTypeURL())
|
||||
txCfg := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
account := ak.GetAccount(ctx, granterAddr)
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txCfg,
|
||||
[]sdk.Msg{&msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -277,11 +277,11 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe
|
||||
|
||||
txCfg := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
granteeAcc := ak.GetAccount(ctx, granteeAddr)
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txCfg,
|
||||
[]sdk.Msg{&msgExec},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{granteeAcc.GetAccountNumber()},
|
||||
[]uint64{granteeAcc.GetSequence()},
|
||||
|
||||
@ -57,6 +57,7 @@ func (suite *SimTestSuite) TestWeightedOperations() {
|
||||
for i, w := range weightedOps {
|
||||
op, _, err := w.Op()(r, suite.app.BaseApp, suite.ctx, accs, "")
|
||||
require.NoError(err)
|
||||
|
||||
// the following checks are very much dependent from the ordering of the output given
|
||||
// by WeightedOperations. if the ordering in WeightedOperations changes some tests
|
||||
// will fail
|
||||
|
||||
@ -6,8 +6,8 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
@ -137,11 +137,11 @@ func sendMsgSend(
|
||||
}
|
||||
}
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -350,11 +350,11 @@ func sendMsgMultiSend(
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
accountNumbers,
|
||||
sequenceNumbers,
|
||||
|
||||
@ -53,7 +53,9 @@ func (suite *SimTestSuite) TestWeightedOperations() {
|
||||
}
|
||||
|
||||
for i, w := range weightesOps {
|
||||
operationMsg, _, _ := w.Op()(r, suite.app.BaseApp, suite.ctx, accs, "")
|
||||
operationMsg, _, err := w.Op()(r, suite.app.BaseApp, suite.ctx, accs, "")
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// the following checks are very much dependent from the ordering of the output given
|
||||
// by WeightedOperations. if the ordering in WeightedOperations changes some tests
|
||||
// will fail
|
||||
|
||||
@ -45,7 +45,9 @@ func (suite *SimTestSuite) TestWeightedOperations() {
|
||||
}
|
||||
|
||||
for i, w := range weightesOps {
|
||||
operationMsg, _, _ := w.Op()(r, suite.app.BaseApp, suite.ctx, accs, "")
|
||||
operationMsg, _, err := w.Op()(r, suite.app.BaseApp, suite.ctx, accs, "")
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// the following checks are very much dependent from the ordering of the output given
|
||||
// by WeightedOperations. if the ordering in WeightedOperations changes some tests
|
||||
// will fail
|
||||
|
||||
@ -85,7 +85,9 @@ func (suite *SimTestSuite) TestWeightedOperations() {
|
||||
}
|
||||
|
||||
for i, w := range weightedOps {
|
||||
operationMsg, _, _ := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID())
|
||||
operationMsg, _, err := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID())
|
||||
require.NoError(err)
|
||||
|
||||
// the following checks are very much dependent from the ordering of the output given
|
||||
// by WeightedOperations. if the ordering in WeightedOperations changes some tests
|
||||
// will fail
|
||||
|
||||
@ -10,8 +10,8 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
@ -232,11 +232,11 @@ func (suite *GenTxTestSuite) TestDeliverGenTxs() {
|
||||
_ = suite.setAccountBalance(addr2, 1)
|
||||
|
||||
msg := banktypes.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)})
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
suite.encodingConfig.TxConfig,
|
||||
[]sdk.Msg{msg},
|
||||
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10)},
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
suite.ctx.ChainID(),
|
||||
[]uint64{7},
|
||||
[]uint64{0},
|
||||
|
||||
@ -7,8 +7,8 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
||||
@ -170,11 +170,11 @@ func SimulateMsgSubmitProposal(
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
|
||||
@ -86,6 +86,8 @@ func TestWeightedOperations(t *testing.T) {
|
||||
|
||||
for i, w := range weightesOps {
|
||||
operationMsg, _, _ := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID())
|
||||
// require.NoError(t, err) // TODO check if it should be NoError
|
||||
|
||||
// the following checks are very much dependent from the ordering of the output given
|
||||
// by WeightedOperations. if the ordering in WeightedOperations changes some tests
|
||||
// will fail
|
||||
|
||||
@ -10,8 +10,8 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@ -261,11 +261,11 @@ func SimulateMsgCreateGroup(ak group.AccountKeeper, bk group.BankKeeper) simtype
|
||||
msg := &group.MsgCreateGroup{Admin: accAddr, Members: members, Metadata: simtypes.RandStringOfLength(r, 10)}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -320,11 +320,11 @@ func SimulateMsgCreateGroupWithPolicy(ak group.AccountKeeper, bk group.BankKeepe
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -379,11 +379,11 @@ func SimulateMsgCreateGroupPolicy(ak group.AccountKeeper, bk group.BankKeeper, k
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -454,11 +454,11 @@ func SimulateMsgSubmitProposal(ak group.AccountKeeper, bk group.BankKeeper, k ke
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{&msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -513,11 +513,11 @@ func SimulateMsgUpdateGroupAdmin(ak group.AccountKeeper, bk group.BankKeeper, k
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{&msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -563,11 +563,11 @@ func SimulateMsgUpdateGroupMetadata(ak group.AccountKeeper, bk group.BankKeeper,
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{&msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -642,11 +642,11 @@ func SimulateMsgUpdateGroupMembers(ak group.AccountKeeper,
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{&msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -701,11 +701,11 @@ func SimulateMsgUpdateGroupPolicyAdmin(ak group.AccountKeeper, bk group.BankKeep
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{&msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -762,11 +762,11 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy(ak group.AccountKeeper,
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -813,11 +813,11 @@ func SimulateMsgUpdateGroupPolicyMetadata(ak group.AccountKeeper,
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{&msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -915,11 +915,11 @@ func SimulateMsgWithdrawProposal(ak group.AccountKeeper,
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{&msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{proposerAcc.GetAccountNumber()},
|
||||
[]uint64{proposerAcc.GetSequence()},
|
||||
@ -1020,11 +1020,11 @@ func SimulateMsgVote(ak group.AccountKeeper,
|
||||
Metadata: simtypes.RandStringOfLength(r, 10),
|
||||
}
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{&msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -1098,11 +1098,11 @@ func SimulateMsgExec(ak group.AccountKeeper,
|
||||
Executor: acc.Address.String(),
|
||||
}
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{&msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
@ -1160,11 +1160,11 @@ func SimulateMsgLeaveGroup(k keeper.Keeper, ak group.AccountKeeper, bk group.Ban
|
||||
}
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
|
||||
@ -67,7 +67,9 @@ func (suite *SimTestSuite) TestWeightedOperations() {
|
||||
}
|
||||
|
||||
for i, w := range weightedOps {
|
||||
operationMsg, _, _ := w.Op()(r, suite.app.BaseApp, suite.ctx, accs, "")
|
||||
operationMsg, _, err := w.Op()(r, suite.app.BaseApp, suite.ctx, accs, "")
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// the following checks are very much dependent from the ordering of the output given
|
||||
// by WeightedOperations. if the ordering in WeightedOperations changes some tests
|
||||
// will fail
|
||||
|
||||
@ -6,15 +6,14 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
"github.com/cosmos/cosmos-sdk/x/nft"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/nft/keeper"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/nft"
|
||||
"github.com/cosmos/cosmos-sdk/x/nft/keeper"
|
||||
)
|
||||
|
||||
//nolint:gosec // these are not hardcoded credentials.
|
||||
@ -97,26 +96,26 @@ func SimulateMsgSend(
|
||||
}
|
||||
|
||||
txCfg := tx.NewTxConfig(cdc, tx.DefaultSignModes)
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txCfg,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{senderAcc.GetAccountNumber()},
|
||||
[]uint64{senderAcc.GetSequence()},
|
||||
sender.PrivKey,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return simtypes.NoOpMsg(nft.ModuleName, TypeMsgSend, "unable to generate mock tx"), nil, err
|
||||
}
|
||||
|
||||
_, _, err = app.SimDeliver(txCfg.TxEncoder(), tx)
|
||||
if err != nil {
|
||||
if _, _, err = app.SimDeliver(txCfg.TxEncoder(), tx); err != nil {
|
||||
return simtypes.NoOpMsg(nft.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, err
|
||||
}
|
||||
|
||||
return simtypes.NewOperationMsg(msg, true, "", cdc), nil, err
|
||||
return simtypes.NewOperationMsg(msg, true, "", cdc), nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,6 +54,13 @@ func (suite *SimTestSuite) SetupTest() {
|
||||
|
||||
suite.app = app
|
||||
suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{})
|
||||
|
||||
suite.app.BeginBlock(abci.RequestBeginBlock{
|
||||
Header: tmproto.Header{
|
||||
Height: suite.app.LastBlockHeight() + 1,
|
||||
AppHash: suite.app.LastCommitID().Hash,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (suite *SimTestSuite) TestWeightedOperations() {
|
||||
@ -80,12 +87,14 @@ func (suite *SimTestSuite) TestWeightedOperations() {
|
||||
}
|
||||
|
||||
for i, w := range weightedOps {
|
||||
operationMsg, _, _ := w.Op()(r, suite.app.BaseApp, suite.ctx, accs, "")
|
||||
operationMsg, _, err := w.Op()(r, suite.app.BaseApp, suite.ctx, accs, "")
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// the following checks are very much dependent from the ordering of the output given
|
||||
// by WeightedOperations. if the ordering in WeightedOperations changes some tests
|
||||
// will fail
|
||||
suite.Require().Equal(expected[i].weight, w.Weight(), "weight should be the same")
|
||||
suite.Require().Contains(expected[i].opMsgRoute, operationMsg.Route, "route should be the same")
|
||||
suite.Require().Equal(expected[i].opMsgRoute, operationMsg.Route, "route should be the same")
|
||||
suite.Require().Equal(expected[i].opMsgName, operationMsg.Name, "operation Msg name should be the same")
|
||||
}
|
||||
}
|
||||
@ -113,14 +122,6 @@ func (suite *SimTestSuite) TestSimulateMsgSend() {
|
||||
blockTime := time.Now().UTC()
|
||||
ctx := suite.ctx.WithBlockTime(blockTime)
|
||||
|
||||
// begin a new block
|
||||
suite.app.BeginBlock(abci.RequestBeginBlock{
|
||||
Header: tmproto.Header{
|
||||
Height: suite.app.LastBlockHeight() + 1,
|
||||
AppHash: suite.app.LastCommitID().Hash,
|
||||
},
|
||||
})
|
||||
|
||||
// execute operation
|
||||
registry := suite.interfaceRegistry
|
||||
op := simulation.SimulateMsgSend(codec.NewProtoCodec(registry), suite.accountKeeper, suite.bankKeeper, suite.nftKeeper)
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
)
|
||||
@ -100,11 +100,11 @@ func GenAndDeliverTxWithRandFees(txCtx OperationInput) (simtypes.OperationMsg, [
|
||||
// GenAndDeliverTx generates a transactions and delivers it.
|
||||
func GenAndDeliverTx(txCtx OperationInput, fees sdk.Coins) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
|
||||
account := txCtx.AccountKeeper.GetAccount(txCtx.Context, txCtx.SimAccount.Address)
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txCtx.TxGen,
|
||||
[]sdk.Msg{txCtx.Msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
txCtx.Context.ChainID(),
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
|
||||
@ -6,8 +6,8 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
@ -88,11 +88,11 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee
|
||||
msg := types.NewMsgUnjail(validator.GetOperator())
|
||||
|
||||
txGen := simappparams.MakeTestEncodingConfig().TxConfig
|
||||
tx, err := helpers.GenSignedMockTx(
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
txGen,
|
||||
[]sdk.Msg{msg},
|
||||
fees,
|
||||
helpers.DefaultGenTxGas,
|
||||
simtestutil.DefaultGenTxGas,
|
||||
chainID,
|
||||
[]uint64{account.GetAccountNumber()},
|
||||
[]uint64{account.GetSequence()},
|
||||
|
||||
@ -44,7 +44,9 @@ func TestWeightedOperations(t *testing.T) {
|
||||
|
||||
weightesOps := simulation.WeightedOperations(appParams, cdc, app.AccountKeeper, app.BankKeeper, app.SlashingKeeper, app.StakingKeeper)
|
||||
for i, w := range weightesOps {
|
||||
operationMsg, _, _ := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID())
|
||||
operationMsg, _, err := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID())
|
||||
require.NoError(t, err)
|
||||
|
||||
// the following checks are very much dependent from the ordering of the output given
|
||||
// by WeightedOperations. if the ordering in WeightedOperations changes some tests
|
||||
// will fail
|
||||
|
||||
@ -57,6 +57,8 @@ func TestWeightedOperations(t *testing.T) {
|
||||
|
||||
for i, w := range weightesOps {
|
||||
operationMsg, _, _ := w.Op()(r, app.BaseApp, ctx, accs, ctx.ChainID())
|
||||
// require.NoError(t, err) // TODO check if it should be NoError
|
||||
|
||||
// the following checks are very much dependent from the ordering of the output given
|
||||
// by WeightedOperations. if the ordering in WeightedOperations changes some tests
|
||||
// will fail
|
||||
|
||||
Loading…
Reference in New Issue
Block a user