-
Notifications
You must be signed in to change notification settings - Fork 51
/
module_simulation.go
128 lines (112 loc) · 3.9 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
package oracle
import (
"math/rand"
"github.com/cosmos/cosmos-sdk/baseapp"
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/elys-network/elys/testutil/sample"
oraclesimulation "github.com/elys-network/elys/x/oracle/simulation"
"github.com/elys-network/elys/x/oracle/types"
)
// avoid unused import issue
var (
_ = sample.AccAddress
_ = oraclesimulation.FindAccount
_ = simulation.MsgEntryKind
_ = baseapp.Paramspace
)
const (
opWeightMsgFeedPrice = "op_weight_msg_price"
// TODO: Determine the simulation weight value
defaultWeightMsgFeedPrice int = 100
opWeightMsgDeletePriceFeeder = "op_weight_msg_price_feeder"
// TODO: Determine the simulation weight value
defaultWeightMsgDeletePriceFeeder int = 100
opWeightMsgFeedMultiplePrices = "op_weight_msg_feed_multiple_prices"
// TODO: Determine the simulation weight value
defaultWeightMsgFeedMultiplePrices 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()
}
oracleGenesis := types.GenesisState{
Params: types.DefaultParams(),
PortId: types.PortID,
AssetInfos: []types.AssetInfo{
{
Denom: "satoshi",
},
{
Denom: "wei",
},
},
Prices: []types.Price{
{
Provider: sample.AccAddress(),
Asset: "BTC",
Price: sdk.ZeroDec(),
},
{
Provider: sample.AccAddress(),
Asset: "BTC",
Price: sdk.OneDec(),
},
},
PriceFeeders: []types.PriceFeeder{
{
Feeder: sample.AccAddress(),
IsActive: true,
},
},
// this line is used by starport scaffolding # simapp/module/genesisState
}
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&oracleGenesis)
}
// ProposalContents doesn't return any content functions for governance proposals
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}
// 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 weightMsgFeedPrice int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgFeedPrice, &weightMsgFeedPrice, nil,
func(_ *rand.Rand) {
weightMsgFeedPrice = defaultWeightMsgFeedPrice
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgFeedPrice,
oraclesimulation.SimulateMsgFeedPrice(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgDeletePriceFeeder int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDeletePriceFeeder, &weightMsgDeletePriceFeeder, nil,
func(_ *rand.Rand) {
weightMsgDeletePriceFeeder = defaultWeightMsgDeletePriceFeeder
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgDeletePriceFeeder,
oraclesimulation.SimulateMsgDeletePriceFeeder(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgFeedMultiplePrices int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgFeedMultiplePrices, &weightMsgFeedMultiplePrices, nil,
func(_ *rand.Rand) {
weightMsgFeedMultiplePrices = defaultWeightMsgFeedMultiplePrices
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgFeedMultiplePrices,
oraclesimulation.SimulateMsgFeedMultiplePrices(am.accountKeeper, am.bankKeeper, am.keeper),
))
// this line is used by starport scaffolding # simapp/module/operation
return operations
}