laconicd/x/registry/simulation/genesis.go

39 lines
1.4 KiB
Go
Raw Normal View History

2022-10-27 07:14:59 +00:00
package simulation
import (
"encoding/json"
"fmt"
2022-10-27 08:38:21 +00:00
"time"
2022-10-27 07:14:59 +00:00
"github.com/cosmos/cosmos-sdk/types/module"
2022-12-09 04:17:14 +00:00
"github.com/cerc-io/laconicd/x/registry/types"
2022-10-27 08:38:21 +00:00
sdk "github.com/cosmos/cosmos-sdk/types"
2022-10-27 07:14:59 +00:00
)
// RandomizedGenState generates a random GenesisState
func RandomizedGenState(simState *module.SimulationState) {
2022-12-09 04:17:14 +00:00
registryParams := types.NewParams(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(int64(simState.Rand.Intn(10000000000)))),
2022-10-27 08:38:21 +00:00
time.Duration(simState.Rand.Intn(1000))*time.Second,
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(int64(simState.Rand.Intn(10000000000)))),
time.Duration(simState.Rand.Intn(1000))*time.Second,
time.Duration(simState.Rand.Intn(1000))*time.Second,
false,
time.Duration(simState.Rand.Intn(1000))*time.Second,
time.Duration(simState.Rand.Intn(1000))*time.Second,
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(int64(simState.Rand.Intn(10000000000)))),
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(int64(simState.Rand.Intn(10000000000)))),
sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(int64(simState.Rand.Intn(10000000000)))),
)
2022-12-09 04:17:14 +00:00
registryGenesis := types.NewGenesisState(registryParams, []types.Record{}, []types.AuthorityEntry{}, []types.NameEntry{})
2022-10-27 07:14:59 +00:00
2022-12-09 04:17:14 +00:00
bz, err := json.MarshalIndent(registryGenesis, "", " ")
2022-10-27 07:14:59 +00:00
if err != nil {
panic(err)
}
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz)
2022-12-09 04:17:14 +00:00
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&registryGenesis)
2022-10-27 07:14:59 +00:00
}