laconicd/x/auction/simulation/genesis.go

33 lines
1.0 KiB
Go
Raw Normal View History

2022-10-27 07:14:59 +00:00
package simulation
import (
"encoding/json"
"fmt"
2022-10-27 08:20:12 +00:00
"time"
2022-10-27 07:14:59 +00:00
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cerc-io/laconicd/x/auction/types"
2022-10-27 08:20:12 +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-10-27 08:20:12 +00:00
auctionParams := types.NewParams(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)))),
)
auctionGenesis := types.NewGenesisState(auctionParams, []*types.Auction{})
2022-10-27 07:14:59 +00:00
bz, err := json.MarshalIndent(auctionGenesis, "", " ")
if err != nil {
panic(err)
}
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz)
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(auctionGenesis)
}