Minor cleanup

This commit is contained in:
Alex Peters
2022-09-14 15:43:29 +02:00
parent 8fc9855a84
commit 2d896aaefe

View File

@@ -114,7 +114,7 @@ func WeightedOperations(
} }
// SimulateMsgStoreCode generates a MsgStoreCode with random values // SimulateMsgStoreCode generates a MsgStoreCode with random values
func SimulateMsgStoreCode(ak types.AccountKeeper, bk simulation.BankKeeper, wasmKeeper WasmKeeper, wasmBz []byte, gas uint64) simtypes.Operation { func SimulateMsgStoreCode(ak types.AccountKeeper, bk BankKeeper, wasmKeeper WasmKeeper, wasmBz []byte, gas uint64) simtypes.Operation {
return func( return func(
r *rand.Rand, r *rand.Rand,
app *baseapp.BaseApp, app *baseapp.BaseApp,
@@ -136,21 +136,7 @@ func SimulateMsgStoreCode(ak types.AccountKeeper, bk simulation.BankKeeper, wasm
WASMByteCode: wasmBz, WASMByteCode: wasmBz,
InstantiatePermission: &config, InstantiatePermission: &config,
} }
txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, bk, nil)
txCtx := simulation.OperationInput{
R: r,
App: app,
TxGen: simappparams.MakeTestEncodingConfig().TxConfig,
Cdc: nil,
Msg: &msg,
MsgType: msg.Type(),
Context: ctx,
SimAccount: simAccount,
AccountKeeper: ak,
Bankkeeper: bk,
ModuleName: types.ModuleName,
}
return GenAndDeliverTxWithRandFees(txCtx, gas) return GenAndDeliverTxWithRandFees(txCtx, gas)
} }
} }
@@ -202,22 +188,7 @@ func SimulateMsgInstantiateContract(ak types.AccountKeeper, bk BankKeeper, wasmK
Msg: []byte(`{}`), Msg: []byte(`{}`),
Funds: deposit, Funds: deposit,
} }
txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, bk, deposit)
txCtx := simulation.OperationInput{
R: r,
App: app,
TxGen: simappparams.MakeTestEncodingConfig().TxConfig,
Cdc: nil,
Msg: &msg,
MsgType: msg.Type(),
Context: ctx,
SimAccount: simAccount,
AccountKeeper: ak,
Bankkeeper: bk,
ModuleName: types.ModuleName,
CoinsSpentInMsg: deposit,
}
return simulation.GenAndDeliverTxWithRandFees(txCtx) return simulation.GenAndDeliverTxWithRandFees(txCtx)
} }
} }
@@ -275,12 +246,31 @@ func SimulateMsgExecuteContract(
return simtypes.NoOpMsg(types.ModuleName, types.MsgExecuteContract{}.Type(), "contract execute payload"), nil, err return simtypes.NoOpMsg(types.ModuleName, types.MsgExecuteContract{}.Type(), "contract execute payload"), nil, err
} }
txCtx := simulation.OperationInput{ txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, bk, deposit)
return simulation.GenAndDeliverTxWithRandFees(txCtx)
}
}
// BuildOperationInput helper to build object
func BuildOperationInput(
r *rand.Rand,
app *baseapp.BaseApp,
ctx sdk.Context,
msg interface {
sdk.Msg
Type() string
},
simAccount simtypes.Account,
ak types.AccountKeeper,
bk BankKeeper,
deposit sdk.Coins,
) simulation.OperationInput {
return simulation.OperationInput{
R: r, R: r,
App: app, App: app,
TxGen: simappparams.MakeTestEncodingConfig().TxConfig, TxGen: simappparams.MakeTestEncodingConfig().TxConfig,
Cdc: nil, Cdc: nil,
Msg: &msg, Msg: msg,
MsgType: msg.Type(), MsgType: msg.Type(),
Context: ctx, Context: ctx,
SimAccount: simAccount, SimAccount: simAccount,
@@ -289,8 +279,6 @@ func SimulateMsgExecuteContract(
ModuleName: types.ModuleName, ModuleName: types.ModuleName,
CoinsSpentInMsg: deposit, CoinsSpentInMsg: deposit,
} }
return simulation.GenAndDeliverTxWithRandFees(txCtx)
}
} }
// DefaultSimulationExecuteContractSelector picks the first contract address // DefaultSimulationExecuteContractSelector picks the first contract address