Documentation ¶
Index ¶
- Variables
- func AddTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress
- func AddTestAddrsFromPubKeys(app *SimApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdk.Int)
- func AddTestAddrsIncremental(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress
- func AppStateFn(cdc codec.CodecProxy, simManager *module.SimulationManager) simtypes.AppStateFn
- func AppStateFromGenesisFileFn(r io.Reader, cdc codec.CodecProxy, genesisFile string) (tmtypes.GenesisDoc, []simtypes.Account)
- func AppStateRandomizedFn(simManager *module.SimulationManager, r *rand.Rand, cdc codec.CodecProxy, ...) (json.RawMessage, []simtypes.Account)
- func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, balances sdk.Coins)
- func CheckExportSimulation(app App, config simtypes.Config, params simtypes.Params) error
- func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress
- func CreateTestPubKeys(numPubKeys int) []cryptotypes2.PubKey
- func FundAccount(app *SimApp, ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins) error
- func GenSequenceOfTxs(txGen client.TxConfig, msgs []ibcmsg.Msg, accNums []uint64, ...) ([]sdk.Tx, error)
- func GetMaccPerms() map[string][]string
- func GetSimulationLog(storeName string, sdr sdk.StoreDecoderRegistry, kvAs, kvBs []kv.Pair) (log string)
- func GetSimulatorFlags()
- func MakeTestEncodingConfig() simappparams.EncodingConfig
- func NewAccHandler(ak auth.AccountKeeper) sdk.AccNonceHandler
- func NewConfigFromFlags() simulation.Config
- func NewPubKeyFromHex(pk string) (res cryptotypes2.PubKey)
- func PreRun(ctx *server.Context) error
- func PrintStats(db dbm.DB)
- func SetupSimulation(dirPrefix, dbName string) (simtypes.Config, dbm.DB, string, log.Logger, bool, error)
- func SignAndDeliver(t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, ...) (sdk.GasInfo, *sdk.Result, error)
- func SimulationOperations(app App, cdc codec.Codec, config simtypes.Config) []simtypes.WeightedOperation
- func TestAddr(addr string, bech string) (sdk.AccAddress, error)
- type App
- type EmptyAppOptions
- type GasPriceIndex
- type GenerateAccountStrategy
- type GenesisState
- type SimApp
- func (app *SimApp) AppCodec() *codec.CodecProxy
- func (app *SimApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock
- func (app *SimApp) Codec() *codec.Codec
- func (o *SimApp) CollectUpgradeModules(m *module.Manager) (map[int64]*upgradetypes.HeightTasks, map[string]params.ParamSet, ...)
- 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) GetBaseApp() *bam.BaseApp
- func (app *SimApp) GetIBCKeeper() *ibc.Keeper
- func (app *SimApp) GetKey(storeKey string) *sdk.KVStoreKey
- func (app *SimApp) GetScopedIBCKeeper() (cap capabilitykeeper.ScopedKeeper)
- func (app *SimApp) GetStakingKeeper() staking.Keeper
- func (app *SimApp) GetSubspace(moduleName string) params.Subspace
- func (app *SimApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain
- func (app *SimApp) LastBlockHeight() int64
- func (app *SimApp) LastCommitID() sdk.CommitID
- func (app *SimApp) LoadHeight(height int64) error
- func (app *SimApp) LoadStartVersion(height int64) error
- func (app *SimApp) Marshal() *codec.CodecProxy
- func (app *SimApp) ModuleAccountAddrs() map[string]bool
- func (app *SimApp) Name() string
- func (app *SimApp) SetOption(req abci.RequestSetOption) (res abci.ResponseSetOption)
- func (app *SimApp) SimulationManager() *module.SimulationManager
- func (o *SimApp) TxConfig() client.TxConfig
- type SimGenesisAccount
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultCLIHome sets the default home directories for the application CLI DefaultCLIHome = os.ExpandEnv("$HOME/.exchaincli") // DefaultNodeHome sets the folder where the applcation data and configuration will be stored DefaultNodeHome = os.ExpandEnv("$HOME/.exchaind") // 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.CommunityPoolSpendProposalHandler, distr.ChangeDistributionTypeProposalHandler, distr.WithdrawRewardEnabledProposalHandler, distr.RewardTruncatePrecisionProposalHandler, dexclient.DelistProposalHandler, farmclient.ManageWhiteListProposalHandler, evmclient.ManageContractDeploymentWhitelistProposalHandler, evmclient.ManageContractBlockedListProposalHandler, evmclient.ManageContractMethodBlockedListProposalHandler, govclient.ManageTreasuresProposalHandler, erc20client.TokenMappingProposalHandler, erc20client.ProxyContractRedirectHandler, wasmclient.UpdateContractAdminProposalHandler, wasmclient.ClearContractAdminProposalHandler, wasmclient.UpdateDeploymentWhitelistProposalHandler, wasmclient.MigrateContractProposalHandler, wasmclient.UpdateWASMContractMethodBlockedListProposalHandler, ), params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, evidence.AppModuleBasic{}, upgrade.AppModuleBasic{}, evm.AppModuleBasic{}, token.AppModuleBasic{}, dex.AppModuleBasic{}, order.AppModuleBasic{}, ammswap.AppModuleBasic{}, farm.AppModuleBasic{}, capabilityModule.AppModuleBasic{}, core.CoreModule{}, capability.CapabilityModuleAdapter{}, transfer.TransferModule{}, erc20.AppModuleBasic{}, mock.AppModuleBasic{}, wasm.AppModuleBasic{}, ) GlobalGpIndex = GasPriceIndex{} )
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
var DefaultConsensusParams = &abci.ConsensusParams{ Block: &abci.BlockParams{ MaxBytes: 200000, MaxGas: 2000000, }, Evidence: &tmproto.EvidenceParams{ MaxAgeNumBlocks: 302400, MaxAgeDuration: 504 * time.Hour, }, Validator: &tmproto.ValidatorParams{ PubKeyTypes: []string{ tmtypes.ABCIPubKeyTypeEd25519, }, }, }
DefaultConsensusParams defines the default Tendermint consensus params used in SimApp testing.
Functions ¶
func AddTestAddrs ¶
AddTestAddrs constructs and returns accNum amount of accounts with an initial balance of accAmt in random order
func AddTestAddrsFromPubKeys ¶
func AddTestAddrsFromPubKeys(app *SimApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdk.Int)
AddTestAddrsFromPubKeys adds the addresses into the SimApp providing only the public keys.
func AddTestAddrsIncremental ¶
func AddTestAddrsIncremental(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress
AddTestAddrs constructs and returns accNum amount of accounts with an initial balance of accAmt in random order
func AppStateFn ¶
func AppStateFn(cdc codec.CodecProxy, 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 AppStateFromGenesisFileFn ¶
func AppStateFromGenesisFileFn(r io.Reader, cdc codec.CodecProxy, genesisFile string) (tmtypes.GenesisDoc, []simtypes.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.CodecProxy, 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 CheckBalance ¶
CheckBalance checks the balance of an account.
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 ¶
func CreateTestPubKeys(numPubKeys int) []cryptotypes2.PubKey
CreateTestPubKeys returns a total of numPubKeys public keys in ascending order.
func FundAccount ¶
FundAccount is a utility function that funds an account by minting and sending the coins to the address TODO(fdymylja): instead of using the mint module account, which has the permission of minting, create a "faucet" account
func GenSequenceOfTxs ¶
func GenSequenceOfTxs(txGen client.TxConfig, msgs []ibcmsg.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...cryptotypes2.PrivKey) ([]sdk.Tx, error)
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, kvAs, kvBs []kv.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 MakeTestEncodingConfig ¶
func MakeTestEncodingConfig() simappparams.EncodingConfig
MakeTestEncodingConfig creates an EncodingConfig for testing. This function should be used only in tests or when creating a new app instance (NewApp*()). App user shouldn't create new codecs - use the app.AppCodec instead. [DEPRECATED]
func NewAccHandler ¶
func NewAccHandler(ak auth.AccountKeeper) sdk.AccNonceHandler
func NewConfigFromFlags ¶
func NewConfigFromFlags() simulation.Config
NewConfigFromFlags creates a simulation from the retrieved values of the flags.
func NewPubKeyFromHex ¶
func NewPubKeyFromHex(pk string) (res cryptotypes2.PubKey)
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 SignAndDeliver ¶
func SignAndDeliver( t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []ibcmsg.Msg, chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes2.PrivKey, ) (sdk.GasInfo, *sdk.Result, error)
SignAndDeliver signs and delivers a transaction. No simulation occurs as the ibc testing package causes checkState and deliverState to diverge in block time.
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 // 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 EmptyAppOptions ¶
type EmptyAppOptions struct{}
EmptyAppOptions is a stub implementing AppOptions
func (EmptyAppOptions) Get ¶
func (ao EmptyAppOptions) Get(o string) interface{}
Get implements AppOptions
type GasPriceIndex ¶
type GenerateAccountStrategy ¶
type GenerateAccountStrategy func(int) []sdk.AccAddress
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 EvmKeeper *evm.Keeper TokenKeeper token.Keeper DexKeeper dex.Keeper OrderKeeper order.Keeper SwapKeeper ammswap.Keeper FarmKeeper farm.Keeper // ibc ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedTransferKeeper capabilitykeeper.ScopedKeeper ScopedIBCMockKeeper capabilitykeeper.ScopedKeeper TransferKeeper ibctransferkeeper.Keeper CapabilityKeeper *capabilitykeeper.Keeper IBCKeeper *ibc.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly Erc20Keeper erc20.Keeper WasmHandler wasmkeeper.HandlerOption // contains filtered or unexported fields }
SimApp implements an extended ABCI application. It is an application that may process transactions through Ethereum's EVM running atop of Tendermint consensus.
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 a new initialized OKExChain application.
func SetupWithGenesisAccounts ¶
func SetupWithGenesisAccounts(genAccs []authexported.GenesisAccount, balances sdk.Coins) *SimApp
SetupWithGenesisAccounts initializes a new SimApp with the provided genesis accounts and possible balances.
func (*SimApp) AppCodec ¶
func (app *SimApp) AppCodec() *codec.CodecProxy
func (*SimApp) BeginBlocker ¶
func (app *SimApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock
BeginBlocker updates every begin block
func (*SimApp) CollectUpgradeModules ¶
func (o *SimApp) CollectUpgradeModules(m *module.Manager) (map[int64]*upgradetypes.HeightTasks, map[string]params.ParamSet, []types.StoreFilter, []types.StoreFilter, []types.VersionFilter)
func (*SimApp) EndBlocker ¶
func (app *SimApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock
EndBlocker 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) GetBaseApp ¶
func (*SimApp) GetIBCKeeper ¶
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) GetScopedIBCKeeper ¶
func (app *SimApp) GetScopedIBCKeeper() (cap capabilitykeeper.ScopedKeeper)
func (*SimApp) GetStakingKeeper ¶
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) InitChainer ¶
func (app *SimApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain
InitChainer updates at chain initialization
func (*SimApp) LastBlockHeight ¶
func (*SimApp) LastCommitID ¶
func (*SimApp) LoadHeight ¶
LoadHeight loads state at a particular height
func (*SimApp) LoadStartVersion ¶
func (*SimApp) Marshal ¶
func (app *SimApp) Marshal() *codec.CodecProxy
func (*SimApp) ModuleAccountAddrs ¶
ModuleAccountAddrs returns all the app's module account addresses.
func (*SimApp) SetOption ¶
func (app *SimApp) SetOption(req abci.RequestSetOption) (res abci.ResponseSetOption)
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