-
Notifications
You must be signed in to change notification settings - Fork 47
/
operations.go
214 lines (190 loc) · 6.85 KB
/
operations.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
package simulation
// DONTCOVER
import (
"math/rand"
feeskeeper "github.com/desmos-labs/desmos/v4/x/fees/keeper"
"github.com/cosmos/cosmos-sdk/codec"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
sim "github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/desmos-labs/desmos/v4/app/params"
"github.com/desmos-labs/desmos/v4/x/subspaces/keeper"
)
// Simulation operation weights constants
// #nosec G101 -- This is a false positive
const (
OpWeightMsgCreateSubspace = "op_weight_msg_create_subspace"
OpWeightMsgEditSubspace = "op_weight_msg_edit_subspace"
OpWeightMsgDeleteSubspace = "op_weight_msg_delete_subspace"
OpWeightMsgCreateSection = "op_weight_msg_create_section"
OpWeightMsgEditSection = "op_weight_msg_edit_section"
OpWeightMsgMoveSection = "op_weight_msg_move_section"
OpWeightMsgDeleteSection = "op_weight_msg_delete_section"
OpWeightMsgCreateUserGroup = "op_weight_msg_create_user_group"
OpWeightMsgEditUserGroup = "op_weight_msg_edit_user_group"
OpWeightMsgMoveUserGroup = "op_weight_msg_move_user_group"
OpWeightMsgSetUserGroupPermissions = "op_weight_msg_set_user_group_permissions"
OpWeightMsgDeleteUserGroup = "op_weight_msg_delete_user_group"
OpWeightMsgAddUserToUserGroup = "op_weight_msg_add_user_to_user_group"
OpWeightMsgRemoveUserFromUserGroup = "op_weight_msg_remove_user_from_user_group"
OpWeightMsgSetUserPermissions = "op_weight_msg_set_user_permissions"
DefaultGasValue = 200_000
)
// WeightedOperations returns all the operations from the module with their respective weights
func WeightedOperations(
appParams simtypes.AppParams, cdc codec.JSONCodec,
k keeper.Keeper, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper, fk feeskeeper.Keeper,
) sim.WeightedOperations {
var weightMsgCreateSubspace int
appParams.GetOrGenerate(cdc, OpWeightMsgCreateSubspace, &weightMsgCreateSubspace, nil,
func(_ *rand.Rand) {
weightMsgCreateSubspace = params.DefaultWeightMsgCreateSubspace
},
)
var weightMsgEditSubspace int
appParams.GetOrGenerate(cdc, OpWeightMsgEditSubspace, &weightMsgEditSubspace, nil,
func(_ *rand.Rand) {
weightMsgEditSubspace = params.DefaultWeightMsgEditSubspace
},
)
var weightMsgDeleteSubspace int
appParams.GetOrGenerate(cdc, OpWeightMsgDeleteSubspace, &weightMsgDeleteSubspace, nil,
func(_ *rand.Rand) {
weightMsgDeleteSubspace = params.DefaultWeightMsgDeleteSubspace
},
)
var weightMsgCreateSection int
appParams.GetOrGenerate(cdc, OpWeightMsgCreateSection, &weightMsgCreateSection, nil,
func(_ *rand.Rand) {
weightMsgCreateSection = params.DefaultWeightMsgCreateSection
},
)
var weightMsgEditSection int
appParams.GetOrGenerate(cdc, OpWeightMsgEditSection, &weightMsgEditSection, nil,
func(_ *rand.Rand) {
weightMsgEditSection = params.DefaultWeightMsgEditSection
},
)
var weightMsgMoveSection int
appParams.GetOrGenerate(cdc, OpWeightMsgMoveSection, &weightMsgMoveSection, nil,
func(_ *rand.Rand) {
weightMsgMoveSection = params.DefaultWeightMsgMoveSection
},
)
var weightMsgDeleteSection int
appParams.GetOrGenerate(cdc, OpWeightMsgDeleteSection, &weightMsgDeleteSection, nil,
func(_ *rand.Rand) {
weightMsgDeleteSection = params.DefaultWeightMsgDeleteSection
},
)
var weightMsgCreateUserGroup int
appParams.GetOrGenerate(cdc, OpWeightMsgCreateUserGroup, &weightMsgCreateUserGroup, nil,
func(_ *rand.Rand) {
weightMsgCreateUserGroup = params.DefaultWeightMsgCreateUserGroup
},
)
var weightMsgEditUserGroup int
appParams.GetOrGenerate(cdc, OpWeightMsgEditUserGroup, &weightMsgEditUserGroup, nil,
func(_ *rand.Rand) {
weightMsgEditUserGroup = params.DefaultWeightMsgEditUserGroup
},
)
var weightMsgMoveUserGroup int
appParams.GetOrGenerate(cdc, OpWeightMsgMoveUserGroup, &weightMsgMoveUserGroup, nil,
func(_ *rand.Rand) {
weightMsgMoveUserGroup = params.DefaultWeightMsgMoveUserGroup
})
var weightMsgSetUserGroupPermissions int
appParams.GetOrGenerate(cdc, OpWeightMsgSetUserGroupPermissions, &weightMsgSetUserGroupPermissions, nil,
func(_ *rand.Rand) {
weightMsgSetUserGroupPermissions = params.DefaultWeightMsgSetUserGroupPermissions
},
)
var weightMsgDeleteUserGroup int
appParams.GetOrGenerate(cdc, OpWeightMsgDeleteUserGroup, &weightMsgDeleteUserGroup, nil,
func(_ *rand.Rand) {
weightMsgDeleteUserGroup = params.DefaultWeightMsgDeleteUserGroup
},
)
var weightMsgAddUserToUserGroup int
appParams.GetOrGenerate(cdc, OpWeightMsgAddUserToUserGroup, &weightMsgAddUserToUserGroup, nil,
func(_ *rand.Rand) {
weightMsgAddUserToUserGroup = params.DefaultWeightMsgAddUserToUserGroup
},
)
var weightMsgRemoveUserFromUserGroup int
appParams.GetOrGenerate(cdc, OpWeightMsgRemoveUserFromUserGroup, &weightMsgRemoveUserFromUserGroup, nil,
func(_ *rand.Rand) {
weightMsgRemoveUserFromUserGroup = params.DefaultWeightMsgRemoveUserFromUserGroup
},
)
var weightMsgSetUserPermissions int
appParams.GetOrGenerate(cdc, OpWeightMsgSetUserPermissions, &weightMsgSetUserPermissions, nil,
func(_ *rand.Rand) {
weightMsgSetUserPermissions = params.DefaultWeightMsgSetUserPermissions
},
)
return sim.WeightedOperations{
sim.NewWeightedOperation(
weightMsgCreateSubspace,
SimulateMsgCreateSubspace(ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgEditSubspace,
SimulateMsgEditSubspace(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgDeleteSubspace,
SimulateMsgDeleteSubspace(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgCreateSection,
SimulateMsgCreateSection(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgEditSection,
SimulateMsgEditSection(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgMoveSection,
SimulateMsgMoveSection(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgDeleteSection,
SimulateMsgDeleteSection(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgCreateUserGroup,
SimulateMsgCreateUserGroup(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgEditUserGroup,
SimulateMsgEditUserGroup(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgMoveUserGroup,
SimulateMsgMoveUserGroup(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgSetUserGroupPermissions,
SimulateMsgSetUserGroupPermissions(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgDeleteUserGroup,
SimulateMsgDeleteUserGroup(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgAddUserToUserGroup,
SimulateMsgAddUserToUserGroup(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgRemoveUserFromUserGroup,
SimulateMsgRemoveUserFromUserGroup(k, ak, bk, fk),
),
sim.NewWeightedOperation(
weightMsgSetUserPermissions,
SimulateMsgSetUserPermissions(k, ak, bk, fk),
),
}
}