mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 15:25:18 +00:00
add simulation stubs to make tests pass
This commit is contained in:
parent
074bb246a8
commit
058e3981c5
@ -2,6 +2,7 @@ package committee
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -10,16 +11,18 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
sim "github.com/cosmos/cosmos-sdk/x/simulation"
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/committee/client/cli"
|
"github.com/kava-labs/kava/x/committee/client/cli"
|
||||||
"github.com/kava-labs/kava/x/committee/client/rest"
|
"github.com/kava-labs/kava/x/committee/client/rest"
|
||||||
|
"github.com/kava-labs/kava/x/committee/simulation"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ module.AppModule = AppModule{}
|
_ module.AppModule = AppModule{}
|
||||||
_ module.AppModuleBasic = AppModuleBasic{}
|
_ module.AppModuleBasic = AppModuleBasic{}
|
||||||
// TODO_ module.AppModuleSimulation = AppModuleSimulation{}
|
_ module.AppModuleSimulation = AppModuleSimulation{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// AppModuleBasic app module basics object
|
// AppModuleBasic app module basics object
|
||||||
@ -67,31 +70,30 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
|
|||||||
|
|
||||||
//____________________________________________________________________________
|
//____________________________________________________________________________
|
||||||
|
|
||||||
// TODO
|
// AppModuleSimulation defines the module simulation functions used by the module.
|
||||||
// // AppModuleSimulation defines the module simulation functions used by the module.
|
type AppModuleSimulation struct{}
|
||||||
// type AppModuleSimulation struct{}
|
|
||||||
|
|
||||||
// // RegisterStoreDecoder registers a decoder for the module's types
|
// RegisterStoreDecoder registers a decoder for the module's types
|
||||||
// func (AppModuleSimulation) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
|
func (AppModuleSimulation) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
|
||||||
// sdr[StoreKey] = simulation.DecodeStore
|
sdr[StoreKey] = simulation.DecodeStore
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // GenerateGenesisState creates a randomized GenState of the module
|
// GenerateGenesisState creates a randomized GenState of the module
|
||||||
// func (AppModuleSimulation) GenerateGenesisState(simState *module.SimulationState) {
|
func (AppModuleSimulation) GenerateGenesisState(simState *module.SimulationState) {
|
||||||
// simulation.RandomizedGenState(simState)
|
simulation.RandomizedGenState(simState)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // RandomizedParams creates randomized param changes for the simulator.
|
// RandomizedParams creates randomized param changes for the simulator.
|
||||||
// func (AppModuleSimulation) RandomizedParams(r *rand.Rand) []sim.ParamChange {
|
func (AppModuleSimulation) RandomizedParams(r *rand.Rand) []sim.ParamChange {
|
||||||
// return simulation.ParamChanges(r)
|
return simulation.ParamChanges(r)
|
||||||
// }
|
}
|
||||||
|
|
||||||
//____________________________________________________________________________
|
//____________________________________________________________________________
|
||||||
|
|
||||||
// AppModule app module type
|
// AppModule app module type
|
||||||
type AppModule struct {
|
type AppModule struct {
|
||||||
AppModuleBasic
|
AppModuleBasic
|
||||||
// TODO AppModuleSimulation
|
AppModuleSimulation
|
||||||
|
|
||||||
keeper Keeper
|
keeper Keeper
|
||||||
}
|
}
|
||||||
|
12
x/committee/simulation/decoder.go
Normal file
12
x/committee/simulation/decoder.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package simulation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
cmn "github.com/tendermint/tendermint/libs/common"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DecodeStore unmarshals the KVPair's Value to the corresponding module type
|
||||||
|
func DecodeStore(cdc *codec.Codec, kvA, kvB cmn.KVPair) string {
|
||||||
|
// TODO implement this
|
||||||
|
return ""
|
||||||
|
}
|
22
x/committee/simulation/genesis.go
Normal file
22
x/committee/simulation/genesis.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package simulation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
|
||||||
|
"github.com/kava-labs/kava/x/auction/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RandomizedGenState generates a random GenesisState for the module
|
||||||
|
func RandomizedGenState(simState *module.SimulationState) {
|
||||||
|
|
||||||
|
// TODO implement this fully
|
||||||
|
// - randomly generating the genesis params
|
||||||
|
// - overwriting with genesis provided to simulation
|
||||||
|
genesisState := types.DefaultGenesisState()
|
||||||
|
|
||||||
|
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, codec.MustMarshalJSONIndent(simState.Cdc, genesisState))
|
||||||
|
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(genesisState)
|
||||||
|
}
|
14
x/committee/simulation/params.go
Normal file
14
x/committee/simulation/params.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package simulation
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ParamChanges defines the parameters that can be modified by param change proposals
|
||||||
|
// on the simulation
|
||||||
|
func ParamChanges(r *rand.Rand) []simulation.ParamChange {
|
||||||
|
// TODO implement this
|
||||||
|
return []simulation.ParamChange{}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user