-
Notifications
You must be signed in to change notification settings - Fork 45
/
operations.go
142 lines (125 loc) · 4.53 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
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/v5/app/params"
"github.com/desmos-labs/desmos/v5/x/profiles/keeper"
)
// Simulation operation weights constants
//
//nolint:gosec // These are not hardcoded credentials
const (
OpWeightMsgSaveProfile = "op_weight_msg_save_profile"
OpWeightMsgDeleteProfile = "op_weight_msg_delete_profile"
OpWeightMsgRequestDTagTransfer = "op_weight_msg_request_dtag_transfer"
OpWeightMsgAcceptDTagTransfer = "op_weight_msg_accept_dtag_transfer_request"
OpWeightMsgRefuseDTagTransfer = "op_weight_msg_refuse_dtag_transfer_request"
OpWeightMsgCancelDTagTransfer = "op_weight_msg_cancel_dtag_transfer_request"
OpWeightMsgLinkChainAccount = "op_weight_msg_link_chain_account"
OpWeightMsgUnlinkChainAccount = "op_weight_msg_unlink_chain_account"
OpWeightSetDefaultExternalAddress = "op_weight_set_default_external_address"
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, ak authkeeper.AccountKeeper, bk bankkeeper.Keeper,
) sim.WeightedOperations {
var weightMsgSaveProfile int
appParams.GetOrGenerate(cdc, OpWeightMsgSaveProfile, &weightMsgSaveProfile, nil,
func(_ *rand.Rand) {
weightMsgSaveProfile = params.DefaultWeightMsgSaveProfile
},
)
var weightMsgDeleteProfile int
appParams.GetOrGenerate(cdc, OpWeightMsgDeleteProfile, &weightMsgDeleteProfile, nil,
func(_ *rand.Rand) {
weightMsgDeleteProfile = params.DefaultWeightMsgDeleteProfile
},
)
var weightMsgRequestDTagTransfer int
appParams.GetOrGenerate(cdc, OpWeightMsgRequestDTagTransfer, &weightMsgRequestDTagTransfer, nil,
func(_ *rand.Rand) {
weightMsgRequestDTagTransfer = params.DefaultWeightMsgRequestDTagTransfer
},
)
var weightMsgAcceptDTagTransfer int
appParams.GetOrGenerate(cdc, OpWeightMsgAcceptDTagTransfer, &weightMsgAcceptDTagTransfer, nil,
func(_ *rand.Rand) {
weightMsgAcceptDTagTransfer = params.DefaultWeightMsgAcceptDTagTransfer
},
)
var weightMsgRefuseDTagTransfer int
appParams.GetOrGenerate(cdc, OpWeightMsgRefuseDTagTransfer, &weightMsgRefuseDTagTransfer, nil,
func(r *rand.Rand) {
weightMsgRefuseDTagTransfer = params.DefaultWeightMsgRefuseDTagTransfer
},
)
var weightMsgCancelDTagTransfer int
appParams.GetOrGenerate(cdc, OpWeightMsgCancelDTagTransfer, &weightMsgCancelDTagTransfer, nil,
func(r *rand.Rand) {
weightMsgCancelDTagTransfer = params.DefaultWeightMsgCancelDTagTransfer
},
)
var weightMsgLinkChainAccount int
appParams.GetOrGenerate(cdc, OpWeightMsgLinkChainAccount, &weightMsgLinkChainAccount, nil,
func(r *rand.Rand) {
weightMsgLinkChainAccount = params.DefaultWeightMsgLinkChainAccount
},
)
var weightMsgUnlinkChainAccount int
appParams.GetOrGenerate(cdc, OpWeightMsgUnlinkChainAccount, &weightMsgUnlinkChainAccount, nil,
func(r *rand.Rand) {
weightMsgUnlinkChainAccount = params.DefaultWeightMsgUnlinkChainAccount
},
)
var weightMsgSetDefaultExternalAddress int
appParams.GetOrGenerate(cdc, OpWeightMsgLinkChainAccount, &weightMsgSetDefaultExternalAddress, nil,
func(r *rand.Rand) {
weightMsgSetDefaultExternalAddress = params.DefaultWeightMsgSetDefaultExternalAddress
},
)
return sim.WeightedOperations{
sim.NewWeightedOperation(
weightMsgSaveProfile,
SimulateMsgSaveProfile(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgDeleteProfile,
SimulateMsgDeleteProfile(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgRequestDTagTransfer,
SimulateMsgRequestDTagTransfer(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgAcceptDTagTransfer,
SimulateMsgAcceptDTagTransfer(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgRefuseDTagTransfer,
SimulateMsgRefuseDTagTransfer(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgCancelDTagTransfer,
SimulateMsgCancelDTagTransfer(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgLinkChainAccount,
SimulateMsgLinkChainAccount(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgUnlinkChainAccount,
SimulateMsgUnlinkChainAccount(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgSetDefaultExternalAddress,
SimulateMsgSetDefaultExternalAddress(k, ak, bk),
),
}
}