forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
39 lines (30 loc) · 967 Bytes
/
genesis.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
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"
"math/rand"
"github.com/eligion/cosmos-sdk/types/module"
"github.com/eligion/cosmos-sdk/x/capability/types"
)
// Simulation parameter constants
const index = "index"
// GenIndex returns a random global index between 1-1000
func GenIndex(r *rand.Rand) uint64 {
return uint64(r.Int63n(1000)) + 1
}
// RandomizedGenState generates a random GenesisState for capability
func RandomizedGenState(simState *module.SimulationState) {
var idx uint64
simState.AppParams.GetOrGenerate(
simState.Cdc, index, &idx, simState.Rand,
func(r *rand.Rand) { idx = GenIndex(r) },
)
capabilityGenesis := types.GenesisState{Index: idx}
bz, err := json.MarshalIndent(&capabilityGenesis, "", " ")
if err != nil {
panic(err)
}
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz)
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&capabilityGenesis)
}