Minor cleanup
This commit is contained in:
@@ -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,24 +246,41 @@ 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)
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DefaultSimulationExecuteContractSelector picks the first contract address
|
// DefaultSimulationExecuteContractSelector picks the first contract address
|
||||||
func DefaultSimulationExecuteContractSelector(ctx sdk.Context, wasmKeeper WasmKeeper) sdk.AccAddress {
|
func DefaultSimulationExecuteContractSelector(ctx sdk.Context, wasmKeeper WasmKeeper) sdk.AccAddress {
|
||||||
var r sdk.AccAddress
|
var r sdk.AccAddress
|
||||||
|
|||||||
Reference in New Issue
Block a user