Documentation ¶
Index ¶
- Variables
- func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simtypes.AppStateFn
- func AppStateRandomizedFn(simManager *module.SimulationManager, r *rand.Rand, cdc *codec.Codec, ...) (json.RawMessage, []simtypes.Account)
- func CheckExportSimulation(app App, config simtypes.Config, params simtypes.Params) error
- func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress
- func CreateTestPubKeys(numPubKeys int) []crypto.PubKey
- func GetSimulatorFlags()
- func NewConfigFromFlags() simulation.Config
- func NewDefaultGenesisState() sdk.GenesisState
- func NewPubKeyFromHex(pk string) (res crypto.PubKey)
- func PrintStats(db dbm.DB)
- func SetupSimulation(dirPrefix, dbName string) (simtypes.Config, dbm.DB, string, log.Logger, bool, error)
- func SignCheckDeliver(t *testing.T, cdc *codec.Codec, app *bam.BaseApp, header abci.Header, ...) (sdk.GasInfo, *sdk.Result, error)
- func SimulationOperations(app App, cdc *codec.Codec, config simtypes.Config) []simtypes.WeightedOperation
- type App
- type GenerateAccountStrategy
Constants ¶
This section is empty.
Variables ¶
var ( FlagGenesisFileValue string FlagParamsFileValue string FlagExportParamsPathValue string FlagExportParamsHeightValue int FlagExportStatePathValue string FlagExportStatsPathValue string FlagSeedValue int64 FlagInitialBlockHeightValue int FlagNumBlocksValue int FlagBlockSizeValue int FlagLeanValue bool FlagCommitValue bool FlagOnOperationValue bool FlagAllInvariantsValue bool FlagEnabledValue bool FlagVerboseValue bool FlagPeriodValue uint FlagGenesisTimeValue int64 )
List of available flags for the simulator
var DefaultConsensusParams = &abci.ConsensusParams{ Block: &abci.BlockParams{ MaxBytes: 200000, MaxGas: 2000000, }, Evidence: &abci.EvidenceParams{ MaxAge: 302400, }, Validator: &abci.ValidatorParams{ PubKeyTypes: []string{ tmtypes.ABCIPubKeyTypeEd25519, tmtypes.ABCIPubKeyTypeSecp256k1, }, }, }
DefaultConsensusParams defines the default Tendermint consensus params used in SimApp testing.
Functions ¶
func AppStateFn ¶
func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simtypes.AppStateFn
AppStateFn returns the initial application state using a genesis or the simulation parameters. It panics if the user provides files for both of them. If a file is not given for the genesis or the sim params, it creates a randomized one.
func AppStateRandomizedFn ¶
func AppStateRandomizedFn( simManager *module.SimulationManager, r *rand.Rand, cdc *codec.Codec, accs []simtypes.Account, genesisTimestamp time.Time, appParams simtypes.AppParams, ) (json.RawMessage, []simtypes.Account)
AppStateRandomizedFn creates calls each module's GenesisState generator function and creates the simulation params
func CheckExportSimulation ¶
CheckExportSimulation exports the app state and simulation parameters to JSON if the export paths are defined.
func ConvertAddrsToValAddrs ¶
func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress
ConvertAddrsToValAddrs converts the provided addresses to ValAddress.
func CreateTestPubKeys ¶
CreateTestPubKeys returns a total of numPubKeys public keys in ascending order.
func GetSimulatorFlags ¶
func GetSimulatorFlags()
GetSimulatorFlags gets the values of all the available simulation flags
func NewConfigFromFlags ¶
func NewConfigFromFlags() simulation.Config
NewConfigFromFlags creates a simulation from the retrieved values of the flags.
func NewDefaultGenesisState ¶
func NewDefaultGenesisState() sdk.GenesisState
NewDefaultGenesisState generates the default state for the application.
func NewPubKeyFromHex ¶
NewPubKeyFromHex returns a PubKey from a hex string.
func PrintStats ¶
PrintStats prints the corresponding statistics from the app DB.
func SetupSimulation ¶
func SetupSimulation(dirPrefix, dbName string) (simtypes.Config, dbm.DB, string, log.Logger, bool, error)
SetupSimulation creates the config, db (levelDB), temporary directory and logger for the simulation tests. If `FlagEnabledValue` is false it skips the current test. Returns error on an invalid db intantiation or temp dir creation.
func SignCheckDeliver ¶
func SignCheckDeliver( t *testing.T, cdc *codec.Codec, app *bam.BaseApp, header abci.Header, msgs []sdk.Msg, accNums, seq []uint64, expSimPass, expPass bool, priv ...crypto.PrivKey, ) (sdk.GasInfo, *sdk.Result, error)
SignCheckDeliver checks a generated signed transaction and simulates a block commitment with the given transaction. A test assertion is made using the parameter 'expPass' against the result. A corresponding result is returned.
func SimulationOperations ¶
func SimulationOperations(app App, cdc *codec.Codec, config simtypes.Config) []simtypes.WeightedOperation
SimulationOperations retrieves the simulation params from the provided file path and returns all the modules weighted operations
Types ¶
type App ¶
type App interface { // The assigned name of the app. Name() string // The application types codec. // NOTE: This shoult be sealed before being returned. Codec() *codec.Codec // Application updates every begin block. BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock // Application updates every end block. EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock // Application update at chain (i.e app) initialization. InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain // Loads the app at a given height. LoadHeight(height int64) error // Exports the state of the application for a genesis file. ExportAppStateAndValidators( forZeroHeight bool, jailWhiteList []string, ) (json.RawMessage, []tmtypes.GenesisValidator, error) // All the registered module account addreses. ModuleAccountAddrs() map[string]bool // Helper for the simulation framework. SimulationManager() *module.SimulationManager }
App implements the common methods for a Cosmos SDK-based application specific blockchain.
type GenerateAccountStrategy ¶
type GenerateAccountStrategy func(int) []sdk.AccAddress