-
Notifications
You must be signed in to change notification settings - Fork 48
/
operations.go
110 lines (95 loc) · 3.65 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
package simulation
// DONTCOVER
import (
"math/rand"
postskeeper "github.com/desmos-labs/desmos/v5/x/posts/keeper"
subspaceskeeper "github.com/desmos-labs/desmos/v5/x/subspaces/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/v5/app/params"
"github.com/desmos-labs/desmos/v5/x/reactions/keeper"
"github.com/desmos-labs/desmos/v5/x/reactions/types"
)
// Simulation operation weights constants
// #nosec G101 -- This is a false positive
const (
OpWeightMsgAddReaction = "op_weight_msg_add_reactions"
OpWeightMsgRemoveReaction = "op_weight_msg_remove_reaction"
OpWeightMsgAddRegisteredReaction = "op_weight_msg_add_registered_reaction"
OpWeightMsgEditRegisteredReaction = "op_weight_msg_edit_registered_reaction"
OpWeightMsgRemoveRegisteredReaction = "op_weight_msg_remove_registered_reaction"
OpWeightMsgSetReactionsParams = "op_weight_msg_set_reactions_params"
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, profilesKeeper types.ProfilesKeeper, sk subspaceskeeper.Keeper, pk postskeeper.Keeper,
ak authkeeper.AccountKeeper, bk bankkeeper.Keeper,
) sim.WeightedOperations {
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 weightMsgAddRegisteredReaction int
appParams.GetOrGenerate(cdc, OpWeightMsgAddRegisteredReaction, &weightMsgAddRegisteredReaction, nil,
func(_ *rand.Rand) {
weightMsgAddRegisteredReaction = params.DefaultWeightMsgAddRegisteredReaction
},
)
var weightMsgEditRegisteredReaction int
appParams.GetOrGenerate(cdc, OpWeightMsgEditRegisteredReaction, &weightMsgEditRegisteredReaction, nil,
func(_ *rand.Rand) {
weightMsgEditRegisteredReaction = params.DefaultWeightMsgEditRegisteredReaction
},
)
var weightMsgRemoveRegisteredReaction int
appParams.GetOrGenerate(cdc, OpWeightMsgRemoveRegisteredReaction, &weightMsgRemoveRegisteredReaction, nil,
func(_ *rand.Rand) {
weightMsgRemoveRegisteredReaction = params.DefaultWeightMsgRemoveRegisteredReaction
},
)
var weightMsgSetReactionsParams int
appParams.GetOrGenerate(cdc, OpWeightMsgSetReactionsParams, &weightMsgSetReactionsParams, nil,
func(_ *rand.Rand) {
weightMsgSetReactionsParams = params.DefaultWeightMsgSetReactionsParams
},
)
return sim.WeightedOperations{
sim.NewWeightedOperation(
weightMsgAddReaction,
SimulateMsgAddReaction(k, profilesKeeper, sk, pk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgRemoveReaction,
SimulateMsgRemoveReaction(k, sk, pk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgAddRegisteredReaction,
SimulateMsgAddRegisteredReaction(sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgEditRegisteredReaction,
SimulateMsgEditRegisteredReaction(k, sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgRemoveRegisteredReaction,
SimulateMsgRemoveRegisteredReaction(k, sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgSetReactionsParams,
SimulateMsgSetReactionsParams(sk, ak, bk),
),
}
}