-
Notifications
You must be signed in to change notification settings - Fork 36
/
genesis.go
46 lines (37 loc) · 1.08 KB
/
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
40
41
42
43
44
45
46
package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"
"math/rand"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/provenance-io/provenance/x/attribute/types"
)
// Simulation parameter constants
const (
MaxValueLength = "max_value_length"
)
// GenMaxValueLength randomized MaxValueLength
func GenMaxValueLength(r *rand.Rand) uint32 {
return r.Uint32()
}
// RandomizedGenState generates a random GenesisState for distribution
func RandomizedGenState(simState *module.SimulationState) {
var maxValueLength uint32
simState.AppParams.GetOrGenerate(
simState.Cdc, MaxValueLength, &maxValueLength, simState.Rand,
func(r *rand.Rand) { maxValueLength = GenMaxValueLength(r) },
)
attributeGenesis := types.GenesisState{
Params: types.Params{
MaxValueLength: maxValueLength,
},
Attributes: []types.Attribute{},
}
bz, err := json.MarshalIndent(&attributeGenesis, "", " ")
if err != nil {
panic(err)
}
fmt.Printf("Selected randomly generated attribute parameters:\n%s\n", bz)
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&attributeGenesis)
}