-
Notifications
You must be signed in to change notification settings - Fork 52
/
module_simulation.go
236 lines (202 loc) · 8.21 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
package commitment
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"
"github.com/elys-network/elys/testutil/sample"
commitmentsimulation "github.com/elys-network/elys/x/commitment/simulation"
"github.com/elys-network/elys/x/commitment/types"
)
// avoid unused import issue
var (
_ = sample.AccAddress
_ = commitmentsimulation.FindAccount
_ = simulation.MsgEntryKind
_ = baseapp.Paramspace
)
const (
opWeightMsgCommitClaimedRewards = "op_weight_msg_commit_tokens"
// TODO: Determine the simulation weight value
defaultWeightMsgCommitClaimedRewards int = 100
opWeightMsgUncommitTokens = "op_weight_msg_uncommit_tokens"
// TODO: Determine the simulation weight value
defaultWeightMsgUncommitTokens int = 100
opWeightMsgClaimReward = "op_weight_msg_withdraw_tokens"
// TODO: Determine the simulation weight value
defaultWeightMsgClaimReward int = 100
opWeightMsgCommitLiquidTokens = "op_weight_msg_commit_liquid_tokens"
// TODO: Determine the simulation weight value
defaultWeightMsgCommitLiquidTokens int = 100
opWeightMsgVest = "op_weight_msg_vest"
// TODO: Determine the simulation weight value
defaultWeightMsgVest int = 100
opWeightMsgCancelVest = "op_weight_msg_cancel_vest"
// TODO: Determine the simulation weight value
defaultWeightMsgCancelVest int = 100
opWeightMsgVestNow = "op_weight_msg_vest_now"
// TODO: Determine the simulation weight value
defaultWeightMsgVestNow int = 100
opWeightMsgUpdateVestingInfo = "op_weight_msg_update_vesting_info"
// TODO: Determine the simulation weight value
defaultWeightMsgUpdateVestingInfo int = 100
opWeightMsgVestLiquid = "op_weight_msg_vest_liquid"
// TODO: Determine the simulation weight value
defaultWeightMsgVestLiquid int = 100
opWeightMsgClaimRewards = "op_weight_msg_claim_rewards"
// TODO: Determine the simulation weight value
defaultWeightMsgClaimRewards int = 100
opWeightMsgStake = "op_weight_msg_stake"
// TODO: Determine the simulation weight value
defaultWeightMsgStake int = 100
opWeightMsgUnstake = "op_weight_msg_unstake"
// TODO: Determine the simulation weight value
defaultWeightMsgUnstake 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()
}
commitmentGenesis := types.GenesisState{
Params: types.DefaultParams(),
// this line is used by starport scaffolding # simapp/module/genesisState
}
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&commitmentGenesis)
}
// ProposalContents doesn't return any content functions for governance proposals
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}
// RegisterStoreDecoder registers a decoder
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {}
// 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 weightMsgCommitClaimedRewards int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCommitClaimedRewards, &weightMsgCommitClaimedRewards, nil,
func(_ *rand.Rand) {
weightMsgCommitClaimedRewards = defaultWeightMsgCommitClaimedRewards
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgCommitClaimedRewards,
commitmentsimulation.SimulateMsgCommitClaimedRewards(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgUncommitTokens int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUncommitTokens, &weightMsgUncommitTokens, nil,
func(_ *rand.Rand) {
weightMsgUncommitTokens = defaultWeightMsgUncommitTokens
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgUncommitTokens,
commitmentsimulation.SimulateMsgUncommitTokens(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgClaimReward int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgClaimReward, &weightMsgClaimReward, nil,
func(_ *rand.Rand) {
weightMsgClaimReward = defaultWeightMsgClaimReward
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgClaimReward,
commitmentsimulation.SimulateMsgClaimReward(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgCommitLiquidTokens int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCommitLiquidTokens, &weightMsgCommitLiquidTokens, nil,
func(_ *rand.Rand) {
weightMsgCommitLiquidTokens = defaultWeightMsgCommitLiquidTokens
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgCommitLiquidTokens,
commitmentsimulation.SimulateMsgCommitLiquidTokens(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgVest int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgVest, &weightMsgVest, nil,
func(_ *rand.Rand) {
weightMsgVest = defaultWeightMsgVest
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgVest,
commitmentsimulation.SimulateMsgVest(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgCancelVest int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCancelVest, &weightMsgCancelVest, nil,
func(_ *rand.Rand) {
weightMsgCancelVest = defaultWeightMsgCancelVest
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgCancelVest,
commitmentsimulation.SimulateMsgCancelVest(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgVestNow int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgVestNow, &weightMsgVestNow, nil,
func(_ *rand.Rand) {
weightMsgVestNow = defaultWeightMsgVestNow
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgVestNow,
commitmentsimulation.SimulateMsgVestNow(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgUpdateVestingInfo int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateVestingInfo, &weightMsgUpdateVestingInfo, nil,
func(_ *rand.Rand) {
weightMsgUpdateVestingInfo = defaultWeightMsgUpdateVestingInfo
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgUpdateVestingInfo,
commitmentsimulation.SimulateMsgUpdateVestingInfo(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgVestLiquid int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgVestLiquid, &weightMsgVestLiquid, nil,
func(_ *rand.Rand) {
weightMsgVestLiquid = defaultWeightMsgVestLiquid
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgVestLiquid,
commitmentsimulation.SimulateMsgVestLiquid(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgClaimRewards int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgClaimRewards, &weightMsgClaimRewards, nil,
func(_ *rand.Rand) {
weightMsgClaimRewards = defaultWeightMsgClaimRewards
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgClaimRewards,
commitmentsimulation.SimulateMsgClaimRewards(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgStake int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgStake, &weightMsgStake, nil,
func(_ *rand.Rand) {
weightMsgStake = defaultWeightMsgStake
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgStake,
commitmentsimulation.SimulateMsgStake(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgUnstake int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUnstake, &weightMsgUnstake, nil,
func(_ *rand.Rand) {
weightMsgUnstake = defaultWeightMsgUnstake
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgUnstake,
commitmentsimulation.SimulateMsgUnstake(am.accountKeeper, am.bankKeeper, am.keeper),
))
// this line is used by starport scaffolding # simapp/module/operation
return operations
}