refactor: create TxConfig directly in simulations (#15749)
This commit is contained in:
parent
9a5413dbaa
commit
7a92fd0f1f
@ -41,3 +41,9 @@ func MakeTestEncodingConfig(modules ...module.AppModuleBasic) TestEncodingConfig
|
||||
|
||||
return encCfg
|
||||
}
|
||||
|
||||
func MakeTestTxConfig() client.TxConfig {
|
||||
interfaceRegistry := types.NewInterfaceRegistry()
|
||||
cdc := codec.NewProtoCodec(interfaceRegistry)
|
||||
return tx.NewTxConfig(cdc, tx.DefaultSignModes)
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ func TestSendNotEnoughBalance(t *testing.T) {
|
||||
|
||||
sendMsg := types.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)})
|
||||
header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1}
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txConfig := moduletestutil.MakeTestTxConfig()
|
||||
_, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1)
|
||||
require.Error(t, err)
|
||||
|
||||
@ -233,7 +233,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1}
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txConfig := moduletestutil.MakeTestTxConfig()
|
||||
_, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
|
||||
if tc.expPass {
|
||||
require.NoError(t, err)
|
||||
@ -284,7 +284,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1}
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txConfig := moduletestutil.MakeTestTxConfig()
|
||||
_, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -337,7 +337,7 @@ func TestMsgMultiSendDependent(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
header := cmtproto.Header{Height: baseApp.LastBlockHeight() + 1}
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txConfig := moduletestutil.MakeTestTxConfig()
|
||||
_, _, err := simtestutil.SignCheckDeliver(t, txConfig, baseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -441,7 +441,7 @@ func TestMsgSetSendEnabled(t *testing.T) {
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.desc, func(tt *testing.T) {
|
||||
header := cmtproto.Header{Height: s.App.LastBlockHeight() + 1}
|
||||
txGen := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txGen := moduletestutil.MakeTestTxConfig()
|
||||
_, _, err = simtestutil.SignCheckDeliver(tt, txGen, s.App.BaseApp, header, tc.msgs, "", []uint64{0}, tc.accSeqs, tc.expSimPass, tc.expPass, priv1)
|
||||
if len(tc.expInError) > 0 {
|
||||
require.Error(tt, err)
|
||||
|
||||
@ -76,7 +76,7 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) {
|
||||
require.NoError(b, testutil.FundAccount(s.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000))))
|
||||
|
||||
baseApp.Commit()
|
||||
txGen := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txGen := moduletestutil.MakeTestTxConfig()
|
||||
|
||||
// Precompute all txs
|
||||
txs, err := genSequenceOfTxs(txGen, []sdk.Msg{sendMsg1}, []uint64{0}, []uint64{uint64(0)}, b.N, priv1)
|
||||
@ -121,7 +121,7 @@ func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) {
|
||||
require.NoError(b, testutil.FundAccount(s.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000))))
|
||||
|
||||
baseApp.Commit()
|
||||
txGen := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txGen := moduletestutil.MakeTestTxConfig()
|
||||
|
||||
// Precompute all txs
|
||||
txs, err := genSequenceOfTxs(txGen, []sdk.Msg{multiSendMsg1}, []uint64{0}, []uint64{uint64(0)}, b.N, priv1)
|
||||
|
||||
@ -147,7 +147,7 @@ func sendMsgSend(
|
||||
return err
|
||||
}
|
||||
}
|
||||
txGen := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txGen := moduletestutil.MakeTestTxConfig()
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
r,
|
||||
txGen,
|
||||
@ -350,7 +350,7 @@ func sendMsgMultiSend(
|
||||
return err
|
||||
}
|
||||
}
|
||||
txGen := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txGen := moduletestutil.MakeTestTxConfig()
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
r,
|
||||
txGen,
|
||||
|
||||
@ -226,7 +226,7 @@ func simulateMsgSubmitProposal(ak types.AccountKeeper, bk types.BankKeeper, k *k
|
||||
}
|
||||
|
||||
account := ak.GetAccount(ctx, simAccount.Address)
|
||||
txGen := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txGen := moduletestutil.MakeTestTxConfig()
|
||||
tx, err := simtestutil.GenSignedMockTx(
|
||||
r,
|
||||
txGen,
|
||||
@ -317,7 +317,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.K
|
||||
txCtx := simulation.OperationInput{
|
||||
R: r,
|
||||
App: app,
|
||||
TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig,
|
||||
TxGen: moduletestutil.MakeTestTxConfig(),
|
||||
Cdc: nil,
|
||||
Msg: msg,
|
||||
Context: ctx,
|
||||
@ -366,7 +366,7 @@ func operationSimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k *ke
|
||||
txCtx := simulation.OperationInput{
|
||||
R: r,
|
||||
App: app,
|
||||
TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig,
|
||||
TxGen: moduletestutil.MakeTestTxConfig(),
|
||||
Cdc: nil,
|
||||
Msg: msg,
|
||||
Context: ctx,
|
||||
@ -417,7 +417,7 @@ func operationSimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeepe
|
||||
txCtx := simulation.OperationInput{
|
||||
R: r,
|
||||
App: app,
|
||||
TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig,
|
||||
TxGen: moduletestutil.MakeTestTxConfig(),
|
||||
Cdc: nil,
|
||||
Msg: msg,
|
||||
Context: ctx,
|
||||
@ -460,7 +460,7 @@ func SimulateMsgCancelProposal(ak types.AccountKeeper, bk types.BankKeeper, k *k
|
||||
txCtx := simulation.OperationInput{
|
||||
R: r,
|
||||
App: app,
|
||||
TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig,
|
||||
TxGen: moduletestutil.MakeTestTxConfig(),
|
||||
Cdc: nil,
|
||||
Msg: msg,
|
||||
Context: ctx,
|
||||
|
||||
@ -77,7 +77,7 @@ func TestSlashingMsgs(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
header := cmtproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txConfig := moduletestutil.MakeTestTxConfig()
|
||||
_, _, err = sims.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1)
|
||||
require.NoError(t, err)
|
||||
require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1)))
|
||||
|
||||
@ -68,7 +68,7 @@ func TestStakingMsgs(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
header := cmtproto.Header{Height: app.LastBlockHeight() + 1}
|
||||
txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig
|
||||
txConfig := moduletestutil.MakeTestTxConfig()
|
||||
_, _, err = simtestutil.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1)
|
||||
require.NoError(t, err)
|
||||
require.True(t, sdk.Coins{genCoin.Sub(bondCoin)}.Equal(bankKeeper.GetAllBalances(ctxCheck, addr1)))
|
||||
|
||||
@ -177,7 +177,7 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k *
|
||||
txCtx := simulation.OperationInput{
|
||||
R: r,
|
||||
App: app,
|
||||
TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig,
|
||||
TxGen: moduletestutil.MakeTestTxConfig(),
|
||||
Cdc: nil,
|
||||
Msg: msg,
|
||||
Context: ctx,
|
||||
@ -235,7 +235,7 @@ func SimulateMsgEditValidator(ak types.AccountKeeper, bk types.BankKeeper, k *ke
|
||||
txCtx := simulation.OperationInput{
|
||||
R: r,
|
||||
App: app,
|
||||
TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig,
|
||||
TxGen: moduletestutil.MakeTestTxConfig(),
|
||||
Cdc: nil,
|
||||
Msg: msg,
|
||||
Context: ctx,
|
||||
@ -302,7 +302,7 @@ func SimulateMsgDelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.
|
||||
txCtx := simulation.OperationInput{
|
||||
R: r,
|
||||
App: app,
|
||||
TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig,
|
||||
TxGen: moduletestutil.MakeTestTxConfig(),
|
||||
Cdc: nil,
|
||||
Msg: msg,
|
||||
Context: ctx,
|
||||
@ -379,7 +379,7 @@ func SimulateMsgUndelegate(ak types.AccountKeeper, bk types.BankKeeper, k *keepe
|
||||
txCtx := simulation.OperationInput{
|
||||
R: r,
|
||||
App: app,
|
||||
TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig,
|
||||
TxGen: moduletestutil.MakeTestTxConfig(),
|
||||
Cdc: nil,
|
||||
Msg: msg,
|
||||
Context: ctx,
|
||||
@ -460,7 +460,7 @@ func SimulateMsgCancelUnbondingDelegate(ak types.AccountKeeper, bk types.BankKee
|
||||
txCtx := simulation.OperationInput{
|
||||
R: r,
|
||||
App: app,
|
||||
TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig,
|
||||
TxGen: moduletestutil.MakeTestTxConfig(),
|
||||
Cdc: nil,
|
||||
Msg: msg,
|
||||
Context: ctx,
|
||||
@ -563,7 +563,7 @@ func SimulateMsgBeginRedelegate(ak types.AccountKeeper, bk types.BankKeeper, k *
|
||||
txCtx := simulation.OperationInput{
|
||||
R: r,
|
||||
App: app,
|
||||
TxGen: moduletestutil.MakeTestEncodingConfig().TxConfig,
|
||||
TxGen: moduletestutil.MakeTestTxConfig(),
|
||||
Cdc: nil,
|
||||
Msg: msg,
|
||||
Context: ctx,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user