Skip to content

Commit

Permalink
refactor: rename GenTx to GenSignedMockTx to avoid confusion with…
Browse files Browse the repository at this point in the history
… genutil/GenTx (#11696)
  • Loading branch information
anilcse committed Apr 20, 2022
1 parent df61142 commit 1a9654f
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions simapp/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down Expand Up @@ -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)},
Expand Down
6 changes: 3 additions & 3 deletions x/authz/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions x/bank/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func sendMsgSend(
}
}
txGen := simappparams.MakeTestEncodingConfig().TxConfig
tx, err := helpers.GenTx(
tx, err := helpers.GenSignedMockTx(
txGen,
[]sdk.Msg{msg},
fees,
Expand Down Expand Up @@ -360,7 +360,7 @@ func sendMsgMultiSend(
}

txGen := simappparams.MakeTestEncodingConfig().TxConfig
tx, err := helpers.GenTx(
tx, err := helpers.GenSignedMockTx(
txGen,
[]sdk.Msg{msg},
fees,
Expand Down
2 changes: 1 addition & 1 deletion x/genutil/gentx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down
2 changes: 1 addition & 1 deletion x/gov/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func SimulateMsgSubmitProposal(
}

txGen := simappparams.MakeTestEncodingConfig().TxConfig
tx, err := helpers.GenTx(
tx, err := helpers.GenSignedMockTx(
txGen,
[]sdk.Msg{msg},
fees,
Expand Down
28 changes: 14 additions & 14 deletions x/group/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion x/nft/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func SimulateMsgSend(
}

txCfg := simappparams.MakeTestEncodingConfig().TxConfig
tx, err := helpers.GenTx(
tx, err := helpers.GenSignedMockTx(
txCfg,
[]sdk.Msg{msg},
fees,
Expand Down
2 changes: 1 addition & 1 deletion x/simulation/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1a9654f

Please sign in to comment.