planetmint-go/x/machine/module_simulation.go
Julian Strobl 05eccd9a8d
[staticcheck] Fix findings
Disable checking in generated `query.pb.gw.go` files.

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-07-07 10:37:22 +02:00

90 lines
2.9 KiB
Go

package machine
import (
"math/rand"
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
"planetmint-go/testutil/sample"
machinesimulation "planetmint-go/x/machine/simulation"
"planetmint-go/x/machine/types"
)
// avoid unused import issue
var (
_ = sample.AccAddress
_ = machinesimulation.FindAccount
_ = simulation.MsgEntryKind
_ = baseapp.Paramspace
_ = rand.Rand{}
)
const (
opWeightMsgAttestMachine = "op_weight_msg_attest_machine"
// TODO: Determine the simulation weight value
defaultWeightMsgAttestMachine int = 100
// this line is used by starport scaffolding # simapp/module/const
)
// GenerateGenesisState creates a randomized GenState of the module.
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
accs := make([]string, len(simState.Accounts))
for i, acc := range simState.Accounts {
accs[i] = acc.Address.String()
}
machineGenesis := types.GenesisState{
Params: types.DefaultParams(),
// this line is used by starport scaffolding # simapp/module/genesisState
}
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&machineGenesis)
}
// RegisterStoreDecoder registers a decoder.
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {
// Implement if needed
}
// ProposalContents doesn't return any content functions for governance proposals.
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg {
return nil
}
// WeightedOperations returns the all the gov module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
operations := make([]simtypes.WeightedOperation, 0)
var weightMsgAttestMachine int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgAttestMachine, &weightMsgAttestMachine, nil,
func(_ *rand.Rand) {
weightMsgAttestMachine = defaultWeightMsgAttestMachine
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgAttestMachine,
machinesimulation.SimulateMsgAttestMachine(am.accountKeeper, am.bankKeeper, am.keeper),
))
// this line is used by starport scaffolding # simapp/module/operation
return operations
}
// ProposalMsgs returns msgs used for governance proposals for simulations.
func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg {
return []simtypes.WeightedProposalMsg{
simulation.NewWeightedProposalMsg(
opWeightMsgAttestMachine,
defaultWeightMsgAttestMachine,
func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg {
machinesimulation.SimulateMsgAttestMachine(am.accountKeeper, am.bankKeeper, am.keeper)
return nil
},
),
// this line is used by starport scaffolding # simapp/module/OpMsg
}
}