-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathutils.go
35 lines (29 loc) · 964 Bytes
/
utils.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
package app
import (
"encoding/json"
"io/ioutil"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/types/simulation"
)
// SimulationOperations retrieves the simulation params from the provided file path
// and returns all the modules weighted operations
func SimulationOperations(app *RegenApp, cdc codec.Codec, config simulation.Config) []simulation.WeightedOperation {
simState := module.SimulationState{
AppParams: make(simulation.AppParams),
Cdc: cdc,
}
if config.ParamsFile != "" {
bz, err := ioutil.ReadFile(config.ParamsFile)
if err != nil {
panic(err)
}
err = json.Unmarshal(bz, &simState.AppParams)
if err != nil {
panic(err)
}
}
simState.ParamChanges = app.SimulationManager().GenerateParamChanges(config.Seed)
simState.Contents = app.SimulationManager().GetProposalContents(simState)
return app.smm.WeightedOperations(simState, app.sm.Modules)
}