/
simulation.go
110 lines (94 loc) · 3.57 KB
/
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
package proof
import (
"math/rand"
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/pokt-network/poktroll/testutil/sample"
proofsimulation "github.com/pokt-network/poktroll/x/proof/simulation"
"github.com/pokt-network/poktroll/x/proof/types"
)
// avoid unused import issue
var (
_ = proofsimulation.FindAccount
_ = rand.Rand{}
_ = sample.AccAddress
_ = sdk.AccAddress{}
_ = simulation.MsgEntryKind
)
const (
opWeightMsgCreateClaim = "op_weight_msg_create_claim"
// TODO: Determine the simulation weight value
defaultWeightMsgCreateClaim int = 100
opWeightMsgSubmitProof = "op_weight_msg_submit_proof"
// TODO: Determine the simulation weight value
defaultWeightMsgSubmitProof 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()
}
proofGenesis := types.GenesisState{
Params: types.DefaultParams(),
// this line is used by starport scaffolding # simapp/module/genesisState
}
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&proofGenesis)
}
// RegisterStoreDecoder registers a decoder.
func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {}
// ProposalContents doesn't return any content functions for governance proposals.
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}
// 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 weightMsgCreateClaim int
simState.AppParams.GetOrGenerate(opWeightMsgCreateClaim, &weightMsgCreateClaim, nil,
func(_ *rand.Rand) {
weightMsgCreateClaim = defaultWeightMsgCreateClaim
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgCreateClaim,
proofsimulation.SimulateMsgCreateClaim(am.accountKeeper, am.keeper),
))
var weightMsgSubmitProof int
simState.AppParams.GetOrGenerate(opWeightMsgSubmitProof, &weightMsgSubmitProof, nil,
func(_ *rand.Rand) {
weightMsgSubmitProof = defaultWeightMsgSubmitProof
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgSubmitProof,
proofsimulation.SimulateMsgSubmitProof(am.accountKeeper, am.keeper),
))
// this line is used by starport scaffolding # simapp/module/operation
return operations
}
// ProposalMsgs returns msgs used for governance proposals for simulations.
func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg {
return []simtypes.WeightedProposalMsg{
simulation.NewWeightedProposalMsg(
opWeightMsgCreateClaim,
defaultWeightMsgCreateClaim,
func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg {
proofsimulation.SimulateMsgCreateClaim(am.accountKeeper, am.keeper)
return nil
},
),
simulation.NewWeightedProposalMsg(
opWeightMsgSubmitProof,
defaultWeightMsgSubmitProof,
func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg {
proofsimulation.SimulateMsgSubmitProof(am.accountKeeper, am.keeper)
return nil
},
),
// this line is used by starport scaffolding # simapp/module/OpMsg
}
}