-
Notifications
You must be signed in to change notification settings - Fork 11
/
module_simulation.go
86 lines (72 loc) · 2.87 KB
/
module_simulation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package ratesync
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"
ratesyncsimulation "github.com/persistenceOne/pstake-native/v2/x/ratesync/simulation"
"github.com/persistenceOne/pstake-native/v2/x/ratesync/types"
)
// avoid unused import issue
var (
_ = ratesyncsimulation.FindAccount
_ = simulation.MsgEntryKind
_ = baseapp.Paramspace
_ = rand.Rand{}
)
const (
opWeightMsgUpdateParams = "op_weight_msg_update_params"
// TODO: Determine the simulation weight value
defaultWeightMsgUpdateParams 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()
}
ratesyncGenesis := types.GenesisState{
Params: types.DefaultParams(),
// this line is used by starport scaffolding # simapp/module/genesisState
}
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&ratesyncGenesis)
}
// RegisterStoreDecoder registers a decoder.
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {}
// 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 weightMsgUpdateParams int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateParams, &weightMsgUpdateParams, nil,
func(_ *rand.Rand) {
weightMsgUpdateParams = defaultWeightMsgUpdateParams
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgUpdateParams,
ratesyncsimulation.SimulateMsgUpdateParams(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(
opWeightMsgUpdateParams,
defaultWeightMsgUpdateParams,
func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg {
ratesyncsimulation.SimulateMsgUpdateParams(am.accountKeeper, am.bankKeeper, am.keeper)
return nil
},
),
// this line is used by starport scaffolding # simapp/module/OpMsg
}
}