/
operations.go
178 lines (158 loc) · 6.07 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
package simulation
// DONTCOVER
import (
"math/rand"
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"
"github.com/cosmos/cosmos-sdk/codec"
sim "github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/desmos-labs/desmos/v6/x/posts/keeper"
"github.com/desmos-labs/desmos/v6/x/posts/types"
)
// Simulation operation weights constants
//
//nolint:gosec // These are not hardcoded credentials
const (
DefaultWeightMsgCreatePost int = 80
DefaultWeightMsgEditPost int = 40
DefaultWeightMsgDeletePost int = 20
DefaultWeightMsgAddPostAttachment int = 50
DefaultWeightMsgRemovePostAttachment int = 50
DefaultWeightMsgAnswerPoll int = 50
DefaultWeightMsgMovePost int = 10
DefaultWeightMsgRequestPostOwnerTransfer int = 10
DefaultWeightMsgCancelPostOwnerTransferRequest int = 10
DefaultWeightMsgAcceptPostOwnerTransferRequest int = 10
DefaultWeightMsgRefusePostOwnerTransferRequest int = 10
OpWeightMsgCreatePost = "op_weight_msg_create_post"
OpWeightMsgEditPost = "op_weight_msg_edit_post"
OpWeightMsgDeletePost = "op_weight_msg_delete_post"
OpWeightMsgAddPostAttachment = "op_weight_msg_add_post_attachment"
OpWeightMsgRemovePostAttachment = "op_weight_msg_remove_post_attachment"
OpWeightMsgAnswerPoll = "op_weight_msg_answer_poll"
OpWeightMsgMovePost = "op_weight_msg_move_post"
OpWeightMsgRequestPostOwnerTransfer = "op_weight_msg_request_post_owner_transfer"
OpWeightMsgCancelPostOwnerTransferRequest = "op_weight_msg_cancel_post_owner_transfer_request"
OpWeightMsgAcceptPostOwnerTransferRequest = "op_weight_msg_accept_post_owner_transfer_request"
OpWeightMsgRefusePostOwnerTransferRequest = "op_weight_msg_refuse_post_owner_transfer_request"
DefaultGasValue = 200000
)
// WeightedOperations returns all the operations from the module with their respective weights
func WeightedOperations(
appParams simtypes.AppParams, cdc codec.JSONCodec,
k *keeper.Keeper, sk types.SubspacesKeeper, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper,
) sim.WeightedOperations {
var weightMsgCreatePost int
appParams.GetOrGenerate(cdc, OpWeightMsgCreatePost, &weightMsgCreatePost, nil,
func(_ *rand.Rand) {
weightMsgCreatePost = DefaultWeightMsgCreatePost
},
)
var weightMsgEditPost int
appParams.GetOrGenerate(cdc, OpWeightMsgEditPost, &weightMsgEditPost, nil,
func(_ *rand.Rand) {
weightMsgEditPost = DefaultWeightMsgEditPost
},
)
var weightMsgDeletePost int
appParams.GetOrGenerate(cdc, OpWeightMsgDeletePost, &weightMsgDeletePost, nil,
func(_ *rand.Rand) {
weightMsgDeletePost = DefaultWeightMsgDeletePost
},
)
var weightMsgAddPostAttachment int
appParams.GetOrGenerate(cdc, OpWeightMsgAddPostAttachment, &weightMsgAddPostAttachment, nil,
func(_ *rand.Rand) {
weightMsgAddPostAttachment = DefaultWeightMsgAddPostAttachment
},
)
var weightMsgRemovePostAttachment int
appParams.GetOrGenerate(cdc, OpWeightMsgRemovePostAttachment, &weightMsgRemovePostAttachment, nil,
func(_ *rand.Rand) {
weightMsgRemovePostAttachment = DefaultWeightMsgRemovePostAttachment
},
)
var weightMsgAnswerPoll int
appParams.GetOrGenerate(cdc, OpWeightMsgAnswerPoll, &weightMsgAnswerPoll, nil,
func(_ *rand.Rand) {
weightMsgAnswerPoll = DefaultWeightMsgAnswerPoll
},
)
var weightMsgMovePost int
appParams.GetOrGenerate(cdc, OpWeightMsgMovePost, &weightMsgMovePost, nil,
func(_ *rand.Rand) {
weightMsgMovePost = DefaultWeightMsgMovePost
},
)
var weightMsgRequestPostOwnerTransfer int
appParams.GetOrGenerate(cdc, OpWeightMsgRequestPostOwnerTransfer, &weightMsgRequestPostOwnerTransfer, nil,
func(r *rand.Rand) {
weightMsgRequestPostOwnerTransfer = DefaultWeightMsgRequestPostOwnerTransfer
},
)
var weightMsgCancelPostOwnerTransferRequest int
appParams.GetOrGenerate(cdc, OpWeightMsgCancelPostOwnerTransferRequest, &weightMsgCancelPostOwnerTransferRequest, nil,
func(r *rand.Rand) {
weightMsgCancelPostOwnerTransferRequest = DefaultWeightMsgCancelPostOwnerTransferRequest
},
)
var weightMsgAcceptPostOwnerTransferRequest int
appParams.GetOrGenerate(cdc, OpWeightMsgAcceptPostOwnerTransferRequest, &weightMsgAcceptPostOwnerTransferRequest, nil,
func(r *rand.Rand) {
weightMsgAcceptPostOwnerTransferRequest = DefaultWeightMsgAcceptPostOwnerTransferRequest
},
)
var weightMsgRefusePostOwnerTransferRequest int
appParams.GetOrGenerate(cdc, OpWeightMsgRefusePostOwnerTransferRequest, &weightMsgRefusePostOwnerTransferRequest, nil,
func(r *rand.Rand) {
weightMsgRefusePostOwnerTransferRequest = DefaultWeightMsgRefusePostOwnerTransferRequest
},
)
return sim.WeightedOperations{
sim.NewWeightedOperation(
weightMsgCreatePost,
SimulateMsgCreatePost(k, sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgEditPost,
SimulateMsgEditPost(k, sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgDeletePost,
SimulateMsgDeletePost(k, sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgAddPostAttachment,
SimulateMsgAddPostAttachment(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgRemovePostAttachment,
SimulateMsgRemovePostAttachment(k, sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgAnswerPoll,
SimulateMsgAnswerPoll(k, sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgMovePost,
SimulateMsgMovePost(k, sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgRequestPostOwnerTransfer,
SimulateMsgRequestPostOwnerTransfer(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgCancelPostOwnerTransferRequest,
SimulateMsgCancelPostOwnerTransferRequest(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgAcceptPostOwnerTransferRequest,
SimulateMsgAcceptPostOwnerTransferRequest(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgRefusePostOwnerTransferRequest,
SimulateMsgRefusePostOwnerTransferRequest(k, ak, bk),
),
}
}