mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 08:15:19 +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 (
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/spf13/cobra"
|
||||
@ -10,16 +11,18 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
sim "github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"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/simulation"
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
// TODO_ module.AppModuleSimulation = AppModuleSimulation{}
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
_ module.AppModuleSimulation = AppModuleSimulation{}
|
||||
)
|
||||
|
||||
// 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.
|
||||
// type AppModuleSimulation struct{}
|
||||
// AppModuleSimulation defines the module simulation functions used by the module.
|
||||
type AppModuleSimulation struct{}
|
||||
|
||||
// // RegisterStoreDecoder registers a decoder for the module's types
|
||||
// func (AppModuleSimulation) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
|
||||
// sdr[StoreKey] = simulation.DecodeStore
|
||||
// }
|
||||
// RegisterStoreDecoder registers a decoder for the module's types
|
||||
func (AppModuleSimulation) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
|
||||
sdr[StoreKey] = simulation.DecodeStore
|
||||
}
|
||||
|
||||
// // GenerateGenesisState creates a randomized GenState of the module
|
||||
// func (AppModuleSimulation) GenerateGenesisState(simState *module.SimulationState) {
|
||||
// simulation.RandomizedGenState(simState)
|
||||
// }
|
||||
// GenerateGenesisState creates a randomized GenState of the module
|
||||
func (AppModuleSimulation) GenerateGenesisState(simState *module.SimulationState) {
|
||||
simulation.RandomizedGenState(simState)
|
||||
}
|
||||
|
||||
// // RandomizedParams creates randomized param changes for the simulator.
|
||||
// func (AppModuleSimulation) RandomizedParams(r *rand.Rand) []sim.ParamChange {
|
||||
// return simulation.ParamChanges(r)
|
||||
// }
|
||||
// RandomizedParams creates randomized param changes for the simulator.
|
||||
func (AppModuleSimulation) RandomizedParams(r *rand.Rand) []sim.ParamChange {
|
||||
return simulation.ParamChanges(r)
|
||||
}
|
||||
|
||||
//____________________________________________________________________________
|
||||
|
||||
// AppModule app module type
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
// TODO AppModuleSimulation
|
||||
AppModuleSimulation
|
||||
|
||||
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