fix: simulations for custom modules' genesis params #43
@ -3,15 +3,30 @@ package simulation
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
|
||||||
"github.com/cerc-io/laconicd/x/nameservice/types"
|
"github.com/cerc-io/laconicd/x/nameservice/types"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RandomizedGenState generates a random GenesisState
|
// RandomizedGenState generates a random GenesisState
|
||||||
func RandomizedGenState(simState *module.SimulationState) {
|
func RandomizedGenState(simState *module.SimulationState) {
|
||||||
nameserviceGenesis := types.DefaultGenesisState()
|
nameserviceParams := types.NewParams(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(int64(simState.Rand.Intn(10000000000)))),
|
||||||
|
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)))),
|
||||||
|
)
|
||||||
|
|
||||||
|
nameserviceGenesis := types.NewGenesisState(nameserviceParams, []types.Record{}, []types.AuthorityEntry{}, []types.NameEntry{})
|
||||||
|
|
||||||
bz, err := json.MarshalIndent(nameserviceGenesis, "", " ")
|
bz, err := json.MarshalIndent(nameserviceGenesis, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -19,5 +34,5 @@ func RandomizedGenState(simState *module.SimulationState) {
|
|||||||
}
|
}
|
||||||
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz)
|
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz)
|
||||||
|
|
||||||
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(nameserviceGenesis)
|
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&nameserviceGenesis)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user