-
Notifications
You must be signed in to change notification settings - Fork 2
/
genesis.go
36 lines (28 loc) · 1.02 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
package simulation
// DONTCOVER
import (
"fmt"
"math/rand"
"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec"
"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/module"
"github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/bank/internal/types"
)
// Simulation parameter constants
const (
SendEnabled = "send_enabled"
)
// GenSendEnabled randomized SendEnabled
func GenSendEnabled(r *rand.Rand) bool {
return r.Int63n(101) <= 95 // 95% chance of transfers being enabled
}
// RandomizedGenState generates a random GenesisState for bank
func RandomizedGenState(simState *module.SimulationState) {
var sendEnabled bool
simState.AppParams.GetOrGenerate(
simState.Cdc, SendEnabled, &sendEnabled, simState.Rand,
func(r *rand.Rand) { sendEnabled = GenSendEnabled(r) },
)
bankGenesis := types.NewGenesisState(sendEnabled)
fmt.Printf("Selected randomly generated bank parameters:\n%s\n", codec.MustMarshalJSONIndent(simState.Cdc, bankGenesis))
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(bankGenesis)
}