From 1a9654f8f57dcb541944750d030132072e89218c Mon Sep 17 00:00:00 2001 From: Anil Kumar Kammari Date: Wed, 20 Apr 2022 20:57:19 +0530 Subject: [PATCH] refactor: rename `GenTx` to `GenSignedMockTx` to avoid confusion with genutil/GenTx (#11696) --- CHANGELOG.md | 1 + simapp/helpers/test_helpers.go | 4 ++-- simapp/test_helpers.go | 4 ++-- x/authz/simulation/operations.go | 6 +++--- x/bank/simulation/operations.go | 4 ++-- x/genutil/gentx_test.go | 2 +- x/gov/simulation/operations.go | 2 +- x/group/simulation/operations.go | 28 ++++++++++++++-------------- x/nft/simulation/operations.go | 2 +- x/simulation/util.go | 2 +- x/slashing/simulation/operations.go | 2 +- 11 files changed, 29 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 361107603..c5df8d99d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -176,6 +176,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* [\#11696](https://github.com/cosmos/cosmos-sdk/pull/11696) Rename `helpers.GenTx` to `GenSignedMockTx` to avoid confusion with genutil's `GenTxCmd`. * (x/auth/vesting) [\#11652](https://github.com/cosmos/cosmos-sdk/pull/11652) Add util functions for `Period(s)` * [\#11630](https://github.com/cosmos/cosmos-sdk/pull/11630) Add SafeSub method to sdk.Coin. * [\#11511](https://github.com/cosmos/cosmos-sdk/pull/11511) Add api server flags to start command. diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index 2d02d58de..0dc88f9b4 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -18,8 +18,8 @@ const ( SimAppChainID = "simulation-app" ) -// GenTx generates a signed mock transaction. -func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { +// 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) { sigs := make([]signing.SignatureV2, len(priv)) // create a random length memo diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 364891a5f..4fe0c2b4d 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -412,7 +412,7 @@ func SignCheckDeliver( chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txCfg, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, @@ -462,7 +462,7 @@ 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.GenTx( + txs[i], err = helpers.GenSignedMockTx( txGen, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index d62f698ae..a20c7f276 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -117,7 +117,7 @@ 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.GenTx( + tx, err := helpers.GenSignedMockTx( txCfg, []sdk.Msg{msg}, fees, @@ -187,7 +187,7 @@ 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.GenTx( + tx, err := helpers.GenSignedMockTx( txCfg, []sdk.Msg{&msg}, fees, @@ -276,7 +276,7 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe txCfg := simappparams.MakeTestEncodingConfig().TxConfig granteeAcc := ak.GetAccount(ctx, granteeAddr) - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txCfg, []sdk.Msg{&msgExec}, fees, diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index 96b0d3d2a..8c0c94f0e 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -138,7 +138,7 @@ func sendMsgSend( } } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -360,7 +360,7 @@ func sendMsgMultiSend( } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index cf70d84be..510c04d8d 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -234,7 +234,7 @@ func (suite *GenTxTestSuite) TestDeliverGenTxs() { _ = suite.setAccountBalance(addr2, 1) msg := banktypes.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)}) - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( suite.encodingConfig.TxConfig, []sdk.Msg{msg}, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10)}, diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 08637c8f6..5963a2d2e 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -170,7 +170,7 @@ func SimulateMsgSubmitProposal( } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index 98e04352b..a81bf4925 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -258,7 +258,7 @@ 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.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -316,7 +316,7 @@ func SimulateMsgCreateGroupWithPolicy(ak group.AccountKeeper, bk group.BankKeepe } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -374,7 +374,7 @@ func SimulateMsgCreateGroupPolicy(ak group.AccountKeeper, bk group.BankKeeper, k } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -448,7 +448,7 @@ func SimulateMsgSubmitProposal(ak group.AccountKeeper, bk group.BankKeeper, k ke } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -506,7 +506,7 @@ func SimulateMsgUpdateGroupAdmin(ak group.AccountKeeper, bk group.BankKeeper, k } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -555,7 +555,7 @@ func SimulateMsgUpdateGroupMetadata(ak group.AccountKeeper, bk group.BankKeeper, } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -632,7 +632,7 @@ func SimulateMsgUpdateGroupMembers(ak group.AccountKeeper, } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -690,7 +690,7 @@ func SimulateMsgUpdateGroupPolicyAdmin(ak group.AccountKeeper, bk group.BankKeep } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -749,7 +749,7 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy(ak group.AccountKeeper, } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -798,7 +798,7 @@ func SimulateMsgUpdateGroupPolicyMetadata(ak group.AccountKeeper, } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -898,7 +898,7 @@ func SimulateMsgWithdrawProposal(ak group.AccountKeeper, } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -1002,7 +1002,7 @@ func SimulateMsgVote(ak group.AccountKeeper, Metadata: simtypes.RandStringOfLength(r, 10), } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -1078,7 +1078,7 @@ func SimulateMsgExec(ak group.AccountKeeper, Executor: acc.Address.String(), } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -1140,7 +1140,7 @@ func SimulateMsgLeaveGroup(k keeper.Keeper, ak group.AccountKeeper, bk group.Ban } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, diff --git a/x/nft/simulation/operations.go b/x/nft/simulation/operations.go index 57cf714a1..975fa5713 100644 --- a/x/nft/simulation/operations.go +++ b/x/nft/simulation/operations.go @@ -99,7 +99,7 @@ func SimulateMsgSend( } txCfg := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txCfg, []sdk.Msg{msg}, fees, diff --git a/x/simulation/util.go b/x/simulation/util.go index f32e1bdf6..4b752609f 100644 --- a/x/simulation/util.go +++ b/x/simulation/util.go @@ -100,7 +100,7 @@ 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.GenTx( + tx, err := helpers.GenSignedMockTx( txCtx.TxGen, []sdk.Msg{txCtx.Msg}, fees, diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index a4c82e0f4..e2f3efd02 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -89,7 +89,7 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee msg := types.NewMsgUnjail(validator.GetOperator()) txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees,