Documentation ¶
Index ¶
- Variables
- func AddTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress
- func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simulation.AppStateFn
- func AppStateFromGenesisFileFn(r io.Reader, cdc *codec.Codec, genesisFile string) (tmtypes.GenesisDoc, []simulation.Account)
- func AppStateRandomizedFn(simManager *module.SimulationManager, r *rand.Rand, cdc *codec.Codec, ...) (json.RawMessage, []simulation.Account)
- func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, exp sdk.Coins)
- func CheckExportSimulation(app App, config simulation.Config, params simulation.Params) error
- func GenSequenceOfTxs(msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, ...) []*auth.StdTx
- func GetMaccPerms() map[string][]string
- func GetSimulationLog(storeName string, sdr sdk.StoreDecoderRegistry, cdc *codec.Codec, ...) (log string)
- func GetSimulatorFlags()
- func MakeCodec() *codec.Codec
- func NewConfigFromFlags() simulation.Config
- func PrintStats(db dbm.DB)
- func SetupSimulation(dirPrefix, dbName string) (simulation.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 simulation.Config) []simulation.WeightedOperation
- type App
- type GenesisState
- type SimApp
- func (app *SimApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock
- func (app *SimApp) BlacklistedAccAddrs() map[string]bool
- func (app *SimApp) Codec() *codec.Codec
- func (app *SimApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock
- func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []string) (appState json.RawMessage, validators []tmtypes.GenesisValidator, err error)
- func (app *SimApp) GetKey(storeKey string) *sdk.KVStoreKey
- func (app *SimApp) GetSubspace(moduleName string) params.Subspace
- func (app *SimApp) GetTKey(storeKey string) *sdk.TransientStoreKey
- func (app *SimApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain
- func (app *SimApp) LoadHeight(height int64) error
- func (app *SimApp) ModuleAccountAddrs() map[string]bool
- func (app *SimApp) Name() string
- func (app *SimApp) SimulationManager() *module.SimulationManager
- type SimGenesisAccount
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultCLIHome default home directories for the application CLI DefaultCLIHome = os.ExpandEnv("$HOME/.simapp") // DefaultNodeHome default home directories for the application daemon DefaultNodeHome = os.ExpandEnv("$HOME/.simapp") // ModuleBasics defines the module BasicManager is in charge of setting up basic, // non-dependant module elements, such as codec registration // and genesis verification. ModuleBasics = module.NewBasicManager( auth.AppModuleBasic{}, supply.AppModuleBasic{}, genutil.AppModuleBasic{}, bank.AppModuleBasic{}, staking.AppModuleBasic{}, mint.AppModuleBasic{}, distr.AppModuleBasic{}, gov.NewAppModuleBasic( paramsclient.ProposalHandler, distr.ProposalHandler, upgradeclient.ProposalHandler, ), params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, upgrade.AppModuleBasic{}, evidence.AppModuleBasic{}, ) )
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 // TODO: Remove in favor of binary search for invariant violation FlagAllInvariantsValue bool FlagEnabledValue bool FlagVerboseValue bool FlagPeriodValue uint FlagGenesisTimeValue int64 )
List of available flags for the simulator
Functions ¶
func AddTestAddrs ¶
AddTestAddrs constructs and returns accNum amount of accounts with an initial balance of accAmt
func AppStateFn ¶
func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simulation.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 AppStateFromGenesisFileFn ¶
func AppStateFromGenesisFileFn(r io.Reader, cdc *codec.Codec, genesisFile string) (tmtypes.GenesisDoc, []simulation.Account)
AppStateFromGenesisFileFn util function to generate the genesis AppState from a genesis.json file.
func AppStateRandomizedFn ¶
func AppStateRandomizedFn( simManager *module.SimulationManager, r *rand.Rand, cdc *codec.Codec, accs []simulation.Account, genesisTimestamp time.Time, appParams simulation.AppParams, ) (json.RawMessage, []simulation.Account)
AppStateRandomizedFn creates calls each module's GenesisState generator function and creates the simulation params
func CheckBalance ¶
CheckBalance checks the balance of an account.
func CheckExportSimulation ¶
func CheckExportSimulation( app App, config simulation.Config, params simulation.Params, ) error
CheckExportSimulation exports the app state and simulation parameters to JSON if the export paths are defined.
func GenSequenceOfTxs ¶
func GenSequenceOfTxs(msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...crypto.PrivKey) []*auth.StdTx
GenSequenceOfTxs generates a set of signed transactions of messages, such that they differ only by having the sequence numbers incremented between every transaction.
func GetMaccPerms ¶
GetMaccPerms returns a copy of the module account permissions
func GetSimulationLog ¶
func GetSimulationLog(storeName string, sdr sdk.StoreDecoderRegistry, cdc *codec.Codec, kvAs, kvBs []tmkv.Pair) (log string)
GetSimulationLog unmarshals the KVPair's Value to the corresponding type based on the each's module store key and the prefix bytes of the KVPair's key.
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 PrintStats ¶
PrintStats prints the corresponding statistics from the app DB.
func SetupSimulation ¶
func SetupSimulation(dirPrefix, dbName string) (simulation.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 simulation.Config) []simulation.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 GenesisState ¶
type GenesisState map[string]json.RawMessage
The genesis state of the blockchain is represented here as a map of raw json messages key'd by a identifier string. The identifier is used to determine which module genesis information belongs to so it may be appropriately routed during init chain. Within this application default genesis information is retrieved from the ModuleBasicManager which populates json from each BasicModule object provided to it during init.
func NewDefaultGenesisState ¶
func NewDefaultGenesisState() GenesisState
NewDefaultGenesisState generates the default state for the application.
type SimApp ¶
type SimApp struct { *bam.BaseApp // keepers AccountKeeper auth.AccountKeeper BankKeeper bank.Keeper SupplyKeeper supply.Keeper StakingKeeper staking.Keeper SlashingKeeper slashing.Keeper MintKeeper mint.Keeper DistrKeeper distr.Keeper GovKeeper gov.Keeper CrisisKeeper crisis.Keeper UpgradeKeeper upgrade.Keeper ParamsKeeper params.Keeper EvidenceKeeper evidence.Keeper // contains filtered or unexported fields }
SimApp extends an ABCI application, but with most of its parameters exported. They are exported for convenience in creating helper functions, as object capabilities aren't needed for testing.
func NewSimApp ¶
func NewSimApp( logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool, invCheckPeriod uint, baseAppOptions ...func(*bam.BaseApp), ) *SimApp
NewSimApp returns a reference to an initialized SimApp.
func SetupWithGenesisAccounts ¶
func SetupWithGenesisAccounts(genAccs []authexported.GenesisAccount) *SimApp
SetupWithGenesisAccounts initializes a new SimApp with the passed in genesis accounts.
func (*SimApp) BeginBlocker ¶
func (app *SimApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock
BeginBlocker application updates every begin block
func (*SimApp) BlacklistedAccAddrs ¶
BlacklistedAccAddrs returns all the app's module account addresses black listed for receiving tokens.
func (*SimApp) Codec ¶
Codec returns SimApp's codec.
NOTE: This is solely to be used for testing purposes as it may be desirable for modules to register their own custom testing types.
func (*SimApp) EndBlocker ¶
func (app *SimApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock
EndBlocker application updates every end block
func (*SimApp) ExportAppStateAndValidators ¶
func (app *SimApp) ExportAppStateAndValidators( forZeroHeight bool, jailWhiteList []string, ) (appState json.RawMessage, validators []tmtypes.GenesisValidator, err error)
ExportAppStateAndValidators exports the state of the application for a genesis file.
func (*SimApp) GetKey ¶
func (app *SimApp) GetKey(storeKey string) *sdk.KVStoreKey
GetKey returns the KVStoreKey for the provided store key.
NOTE: This is solely to be used for testing purposes.
func (*SimApp) GetSubspace ¶
GetSubspace returns a param subspace for a given module name.
NOTE: This is solely to be used for testing purposes.
func (*SimApp) GetTKey ¶
func (app *SimApp) GetTKey(storeKey string) *sdk.TransientStoreKey
GetTKey returns the TransientStoreKey for the provided store key.
NOTE: This is solely to be used for testing purposes.
func (*SimApp) InitChainer ¶
func (app *SimApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain
InitChainer application update at chain initialization
func (*SimApp) LoadHeight ¶
LoadHeight loads a particular height
func (*SimApp) ModuleAccountAddrs ¶
ModuleAccountAddrs returns all the app's module account addresses.
func (*SimApp) SimulationManager ¶
func (app *SimApp) SimulationManager() *module.SimulationManager
SimulationManager implements the SimulationApp interface
type SimGenesisAccount ¶
type SimGenesisAccount struct { *authtypes.BaseAccount // vesting account fields OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"` // total vesting coins upon initialization DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"` // delegated vested coins at time of delegation DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` // delegated vesting coins at time of delegation StartTime int64 `json:"start_time" yaml:"start_time"` // vesting start time (UNIX Epoch time) EndTime int64 `json:"end_time" yaml:"end_time"` // vesting end time (UNIX Epoch time) // module account fields ModuleName string `json:"module_name" yaml:"module_name"` // name of the module account ModulePermissions []string `json:"module_permissions" yaml:"module_permissions"` // permissions of module account }
SimGenesisAccount defines a type that implements the GenesisAccount interface to be used for simulation accounts in the genesis state.
func (SimGenesisAccount) Validate ¶
func (sga SimGenesisAccount) Validate() error
Validate checks for errors on the vesting and module account parameters