/
module_simulation.go
205 lines (177 loc) · 6.46 KB
/
module_simulation.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package gitopia
/*
import (
"math/rand"
"github.com/cosmos/cosmos-sdk/baseapp"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/gitopia/gitopia/v4/testutil/sample"
gitopiasimulation "github.com/gitopia/gitopia/v4/x/gitopia/simulation"
"github.com/gitopia/gitopia/v4/x/gitopia/types"
)
// avoid unused import issue
var (
_ = sample.AccAddress
_ = gitopiasimulation.FindAccount
_ = simappparams.StakePerAccount
_ = simulation.MsgEntryKind
_ = baseapp.Paramspace
)
const (
opWeightMsgCreateTag = "op_weight_msg_tag"
// TODO: Determine the simulation weight value
defaultWeightMsgCreateTag int = 100
opWeightMsgUpdateTag = "op_weight_msg_tag"
// TODO: Determine the simulation weight value
defaultWeightMsgUpdateTag int = 100
opWeightMsgDeleteTag = "op_weight_msg_tag"
// TODO: Determine the simulation weight value
defaultWeightMsgDeleteTag int = 100
opWeightMsgCreateMember = "op_weight_msg_member"
// TODO: Determine the simulation weight value
defaultWeightMsgCreateMember int = 100
opWeightMsgUpdateMember = "op_weight_msg_member"
// TODO: Determine the simulation weight value
defaultWeightMsgUpdateMember int = 100
opWeightMsgDeleteMember = "op_weight_msg_member"
// TODO: Determine the simulation weight value
defaultWeightMsgDeleteMember int = 100
opWeightMsgToggleForcePush = "op_weight_msg_toggle_force_push"
// TODO: Determine the simulation weight value
defaultWeightMsgToggleForcePush int = 100
opWeightMsgExercise = "op_weight_msg_exercise"
// TODO: Determine the simulation weight value
defaultWeightMsgExercise int = 100
// this line is used by starport scaffolding # simapp/module/const
)
// GenerateGenesisState creates a randomized GenState of the module
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
accs := make([]string, len(simState.Accounts))
for i, acc := range simState.Accounts {
accs[i] = acc.Address.String()
}
gitopiaGenesis := types.GenesisState{
TagList: []types.Tag{
{
Id: 0,
},
{
Id: 1,
},
},
TagCount: 2,
MemberList: []types.Member{
{
Id: 0,
Creator: sample.AccAddress(),
},
{
Id: 1,
Creator: sample.AccAddress(),
},
},
MemberCount: 2,
// this line is used by starport scaffolding # simapp/module/genesisState
}
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&gitopiaGenesis)
}
// ProposalContents doesn't return any content functions for governance proposals
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}
// RandomizedParams creates randomized param changes for the simulator
func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange {
return []simtypes.ParamChange{}
}
// RegisterStoreDecoder registers a decoder
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {}
// WeightedOperations returns the all the gov module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
operations := make([]simtypes.WeightedOperation, 0)
var weightMsgCreateTag int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCreateTag, &weightMsgCreateTag, nil,
func(_ *rand.Rand) {
weightMsgCreateTag = defaultWeightMsgCreateTag
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgCreateTag,
gitopiasimulation.SimulateMsgCreateTag(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgUpdateTag int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateTag, &weightMsgUpdateTag, nil,
func(_ *rand.Rand) {
weightMsgUpdateTag = defaultWeightMsgUpdateTag
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgUpdateTag,
gitopiasimulation.SimulateMsgUpdateTag(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgDeleteTag int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDeleteTag, &weightMsgDeleteTag, nil,
func(_ *rand.Rand) {
weightMsgDeleteTag = defaultWeightMsgDeleteTag
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgDeleteTag,
gitopiasimulation.SimulateMsgDeleteTag(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgCreateMember int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCreateMember, &weightMsgCreateMember, nil,
func(_ *rand.Rand) {
weightMsgCreateMember = defaultWeightMsgCreateMember
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgCreateMember,
gitopiasimulation.SimulateMsgCreateMember(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgUpdateMember int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateMember, &weightMsgUpdateMember, nil,
func(_ *rand.Rand) {
weightMsgUpdateMember = defaultWeightMsgUpdateMember
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgUpdateMember,
gitopiasimulation.SimulateMsgUpdateMember(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgDeleteMember int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDeleteMember, &weightMsgDeleteMember, nil,
func(_ *rand.Rand) {
weightMsgDeleteMember = defaultWeightMsgDeleteMember
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgDeleteMember,
gitopiasimulation.SimulateMsgDeleteMember(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgToggleForcePush int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgToggleForcePush, &weightMsgToggleForcePush, nil,
func(_ *rand.Rand) {
weightMsgToggleForcePush = defaultWeightMsgToggleForcePush
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgToggleForcePush,
gitopiasimulation.SimulateMsgToggleForcePush(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgExercise int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgExercise, &weightMsgExercise, nil,
func(_ *rand.Rand) {
weightMsgExercise = defaultWeightMsgExercise
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgExercise,
gitopiasimulation.SimulateMsgExercise(am.accountKeeper, am.bankKeeper, am.keeper),
))
// this line is used by starport scaffolding # simapp/module/operation
return operations
}
*/