-
Notifications
You must be signed in to change notification settings - Fork 44
/
operations.go
83 lines (71 loc) · 2.45 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
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/v7/app/params"
"github.com/desmos-labs/desmos/v7/x/relationships/keeper"
"github.com/desmos-labs/desmos/v7/x/relationships/types"
)
// Simulation operation weights constants
//
//nolint:gosec // These are not hardcoded credentials
const (
OpWeightMsgCreateRelationship = "op_weight_msg_create_relationship"
OpWeightMsgDeleteRelationship = "op_weight_msg_delete_relationship"
OpWeightMsgBlockUser = "op_weight_msg_block_user"
OpWeightMsgUnBlockUser = "op_weight_msg_unblock_user"
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 weightMsgCreateRelationship int
appParams.GetOrGenerate(cdc, OpWeightMsgCreateRelationship, &weightMsgCreateRelationship, nil,
func(_ *rand.Rand) {
weightMsgCreateRelationship = params.DefaultWeightMsgCreateRelationship
},
)
var weightMsgDeleteRelationship int
appParams.GetOrGenerate(cdc, OpWeightMsgDeleteRelationship, &weightMsgDeleteRelationship, nil,
func(_ *rand.Rand) {
weightMsgDeleteRelationship = params.DefaultWeightMsgDeleteRelationship
},
)
var weightMsgBlockUser int
appParams.GetOrGenerate(cdc, OpWeightMsgBlockUser, &weightMsgBlockUser, nil,
func(_ *rand.Rand) {
weightMsgBlockUser = params.DefaultWeightMsgBlockUser
},
)
var weightMsgUnblockUser int
appParams.GetOrGenerate(cdc, OpWeightMsgUnBlockUser, &weightMsgUnblockUser, nil,
func(_ *rand.Rand) {
weightMsgBlockUser = params.DefaultWeightMsgUnblockUser
},
)
return sim.WeightedOperations{
sim.NewWeightedOperation(
weightMsgCreateRelationship,
SimulateMsgCreateRelationship(k, sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgDeleteRelationship,
SimulateMsgDeleteRelationship(k, ak, bk),
),
sim.NewWeightedOperation(
weightMsgBlockUser,
SimulateMsgBlockUser(k, sk, ak, bk),
),
sim.NewWeightedOperation(
weightMsgUnblockUser,
SimulateMsgUnblockUser(k, ak, bk),
),
}
}