-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
52 lines (41 loc) · 1.29 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
47
48
49
50
51
52
package simulation
// DONTCOVER
import (
"encoding/json"
//#nosec
"math/rand"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/furynet/furynetwork/app/params"
"github.com/furynet/furynetwork/x/mint/types"
)
// Simulation parameter constants
const (
Inflation = "inflation"
)
// GenInflation randomized Inflation
func GenInflation(r *rand.Rand) sdk.Dec {
return sdk.NewDec(int64(r.Intn(99))).QuoInt64(100)
}
// GenBlocksPerYear randomized BlocksPerYear
func GenBlocksPerYear(r *rand.Rand) sdk.Dec {
return sdk.NewDec(types.BlocksPerYear)
}
// RandomizedGenState generates a random GenesisState for mint
func RandomizedGenState(simState *module.SimulationState) {
// minter
var inflation sdk.Dec
simState.AppParams.GetOrGenerate(
simState.Cdc, Inflation, &inflation, simState.Rand,
func(r *rand.Rand) { inflation = GenInflation(r) },
)
// params
mintDenom := params.DefaultBondDenom
params := types.NewParams(mintDenom, types.BlocksPerYear, types.DefaultExcludeAmount, types.DefaultParams().Phases)
mintGenesis := types.NewGenesisState(types.InitialMinter(inflation), params)
_, err := json.MarshalIndent(&mintGenesis, "", " ")
if err != nil {
panic(err)
}
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(mintGenesis)
}