/
operations.go
117 lines (101 loc) · 3.29 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
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/v2/app/params"
"github.com/desmos-labs/desmos/v2/x/staging/posts/keeper"
)
// Simulation operation weights constants
const (
OpWeightMsgCreatePost = "op_weight_msg_create_post"
OpWeightMsgEditPost = "op_weight_msg_edit_post"
OpWeightMsgAddReaction = "op_weight_msg_add_reaction"
OpWeightMsgRemoveReaction = "op_weight_msg_remove_reaction"
OpWeightMsgAnswerPoll = "op_weight_msg_answer_poll"
OpWeightMsgRegisterReaction = "op_weight_msg_register_reaction"
OpWeightMsgReportPost = "op_weight_msg_report_post"
DefaultGasValue = 5_000_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,
) sim.WeightedOperations {
var weightMsgCreatePost int
appParams.GetOrGenerate(cdc, OpWeightMsgCreatePost, &weightMsgCreatePost, nil,
func(_ *rand.Rand) {
weightMsgCreatePost = params.DefaultWeightMsgCreatePost
},
)
var weightMsgEditPost int
appParams.GetOrGenerate(cdc, OpWeightMsgEditPost, &weightMsgEditPost, nil,
func(_ *rand.Rand) {
weightMsgEditPost = params.DefaultWeightMsgEditPost
},
)
var weightMsgAddReaction int
appParams.GetOrGenerate(cdc, OpWeightMsgAddReaction, &weightMsgAddReaction, nil,
func(_ *rand.Rand) {
weightMsgAddReaction = params.DefaultWeightMsgAddReaction
},
)
var weightMsgRemoveReaction int
appParams.GetOrGenerate(cdc, OpWeightMsgRemoveReaction, &weightMsgRemoveReaction, nil,
func(_ *rand.Rand) {
weightMsgRemoveReaction = params.DefaultWeightMsgRemoveReaction
},
)
var weightMsgAnswerPoll int
appParams.GetOrGenerate(cdc, OpWeightMsgAnswerPoll, &weightMsgAnswerPoll, nil,
func(_ *rand.Rand) {
weightMsgAnswerPoll = params.DefaultWeightMsgAnswerPoll
},
)
var weightMsgRegisterReaction int
appParams.GetOrGenerate(cdc, OpWeightMsgRegisterReaction, &weightMsgRegisterReaction, nil,
func(_ *rand.Rand) {
weightMsgRegisterReaction = params.DefaultWeightMsgRegisterReaction
},
)
var weightMsgReportPost int
appParams.GetOrGenerate(cdc, OpWeightMsgReportPost, &weightMsgReportPost, nil,
func(_ *rand.Rand) {
weightMsgReportPost = params.DefaultWeightMsgReportPost
},
)
return sim.WeightedOperations{
sim.NewWeightedOperation(
weightMsgCreatePost,
SimulateMsgCreatePost(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgEditPost,
SimulateMsgEditPost(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgRegisterReaction,
SimulateMsgRegisterReaction(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgAddReaction,
SimulateMsgAddPostReaction(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgRemoveReaction,
SimulateMsgRemovePostReaction(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgAnswerPoll,
SimulateMsgAnswerToPoll(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgReportPost,
SimulateMsgReportPost(k, ak, bk),
),
}
}