add simulation stubs to make tests pass

This commit is contained in:
rhuairahrighairigh 2020-03-29 20:50:32 +01:00
parent 074bb246a8
commit 058e3981c5
4 changed files with 69 additions and 19 deletions

View File

@ -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
} }

View 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 ""
}

View 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)
}

View 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{}
}