-
Notifications
You must be signed in to change notification settings - Fork 45
/
genesis.go
35 lines (28 loc) · 980 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
package simulation
import (
"encoding/json"
"fmt"
"math/rand"
"github.com/Nolus-Protocol/nolus-core/x/tax/types"
"github.com/cosmos/cosmos-sdk/types/module"
)
// GenRandomFeeRate generates random FeeRate in range [0-50].
func GenRandomFeeRate(r *rand.Rand) int32 {
return int32(r.Intn(51))
}
// RandomizedGenState generates a random GenesisState for tax.
func RandomizedGenState(simState *module.SimulationState) {
var feeRate int32
simState.AppParams.GetOrGenerate(
simState.Cdc, string(types.KeyFeeRate), &feeRate, simState.Rand,
func(r *rand.Rand) { feeRate = GenRandomFeeRate(r) },
)
params := types.NewParams(feeRate, types.DefaultContractAddress, types.DefaultBaseDenom)
taxGenesis := types.NewGenesisState(params)
bz, err := json.MarshalIndent(&taxGenesis, "", " ")
if err != nil {
panic(err)
}
fmt.Printf("Selected randomly generated tax parameters:\n%s\n", bz)
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(taxGenesis)
}