feat(sims): Add simsx support to modules (#24145)
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
This commit is contained in:
co-authored by
Alex | Interchain Labs
parent
99da3279be
commit
ea908cef68
@@ -1,8 +1,6 @@
|
||||
package simulation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@@ -112,11 +110,5 @@ func RandomizedGenState(simState *module.SimulationState, randGenAccountsFn type
|
||||
genesisAccs := randGenAccountsFn(simState)
|
||||
|
||||
authGenesis := types.NewGenesisState(params, genesisAccs)
|
||||
|
||||
bz, err := json.MarshalIndent(&authGenesis.Params, "", " ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("Selected randomly generated auth parameters:\n%s\n", bz)
|
||||
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(authGenesis)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package simulation
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simsx"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
|
||||
func MsgUpdateParamsFactory() simsx.SimMsgFactoryFn[*types.MsgUpdateParams] {
|
||||
return func(_ context.Context, testData *simsx.ChainDataSource, reporter simsx.SimulationReporter) ([]simsx.SimAccount, *types.MsgUpdateParams) {
|
||||
r := testData.Rand()
|
||||
params := types.DefaultParams()
|
||||
params.MaxMemoCharacters = r.Uint64InRange(1, 1000)
|
||||
params.TxSigLimit = r.Uint64InRange(1, 1000)
|
||||
params.TxSizeCostPerByte = r.Uint64InRange(1, 1000)
|
||||
params.SigVerifyCostED25519 = r.Uint64InRange(1, 1000)
|
||||
params.SigVerifyCostSecp256k1 = r.Uint64InRange(1, 1000)
|
||||
|
||||
return nil, &types.MsgUpdateParams{
|
||||
Authority: testData.ModuleAccountAddress(reporter, "gov"),
|
||||
Params: params,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,14 @@ import (
|
||||
)
|
||||
|
||||
// Simulation operation weights constants
|
||||
// will be removed in the future
|
||||
const (
|
||||
DefaultWeightMsgUpdateParams int = 100
|
||||
|
||||
OpWeightMsgUpdateParams = "op_weight_msg_update_params"
|
||||
OpWeightMsgUpdateParams = "op_weight_msg_update_params"
|
||||
)
|
||||
|
||||
// ProposalMsgs defines the module weighted proposals' contents
|
||||
// migrate to MsgUpdateParamsFactory instead
|
||||
func ProposalMsgs() []simtypes.WeightedProposalMsg {
|
||||
return []simtypes.WeightedProposalMsg{
|
||||
simulation.NewWeightedProposalMsg(
|
||||
@@ -29,6 +30,7 @@ func ProposalMsgs() []simtypes.WeightedProposalMsg {
|
||||
}
|
||||
|
||||
// SimulateMsgUpdateParams returns a random MsgUpdateParams
|
||||
// will be removed in the future
|
||||
func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg {
|
||||
// use the default gov module account address as authority
|
||||
var authority sdk.AccAddress = address.Module("gov")
|
||||
|
||||
Reference in New Issue
Block a user