feat(sims): Add simsx support to modules (#24145)

Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
This commit is contained in:
Alexander Peters
2025-04-02 13:23:36 +00:00
committed by GitHub
co-authored by Alex | Interchain Labs
parent 99da3279be
commit ea908cef68
53 changed files with 2025 additions and 241 deletions
-8
View File
@@ -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)
}
+25
View File
@@ -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,
}
}
}
+4 -2
View File
@@ -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")