simulation genesis

This commit is contained in:
0xmuralik
2022-10-27 12:44:59 +05:30
parent 9f31e1b556
commit d4b13e2859
10 changed files with 209 additions and 2 deletions
+26
View File
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"math/rand"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
@@ -19,6 +20,9 @@ import (
"github.com/cerc-io/laconicd/x/auction/client/cli"
"github.com/cerc-io/laconicd/x/auction/keeper"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cerc-io/laconicd/x/auction/simulation"
"github.com/cerc-io/laconicd/x/auction/types"
)
@@ -140,3 +144,25 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
gs := ExportGenesis(ctx, am.keeper)
return cdc.MustMarshalJSON(&gs)
}
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
simulation.RandomizedGenState(simState)
}
// WeightedOperations returns the all the fee market module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
return nil
}
// RandomizedParams creates randomized fee market param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return nil
}
// RegisterStoreDecoder registers a decoder for fee market module's types
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {}
// ProposalContents doesn't return any content functions for governance proposals.
func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}
+23
View File
@@ -0,0 +1,23 @@
package simulation
import (
"encoding/json"
"fmt"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cerc-io/laconicd/x/auction/types"
)
// RandomizedGenState generates a random GenesisState
func RandomizedGenState(simState *module.SimulationState) {
auctionGenesis := types.DefaultGenesisState()
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)
}
+2 -1
View File
@@ -4,6 +4,7 @@ package types
// chain config values.
func DefaultGenesisState() *GenesisState {
return &GenesisState{
Params: DefaultParams(),
Params: DefaultParams(),
Auctions: []*Auction{},
}
}