Documentation
¶
Index ¶
- Constants
- Variables
- func AddTestAddrs(app *App, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress
- func AddTestAddrsFromPubKeys(app *App, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdk.Int)
- func AddTestAddrsIncremental(app *App, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress
- func BeginBlockForks(ctx sdk.Context, fxcore *App)
- func CheckBalance(t *testing.T, app *App, addr sdk.AccAddress, balances sdk.Coins)
- func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress
- func CreateIncrementalAccounts(accNum int) []sdk.AccAddress
- func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey
- func CustomConsensusParams() *tmproto.ConsensusParams
- func DefaultOldFxBankMetaData(denom string) banktypes.Metadata
- func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, ...) ([]sdk.Tx, error)
- func GenerateGenesisValidator(validatorNum int, initCoins sdk.Coins) (*tmtypes.ValidatorSet, authtypes.GenesisAccounts, []banktypes.Balance)
- func NewDefAppGenesisByDenom(denom string, cdc codec.JSONCodec) map[string]json.RawMessage
- func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey)
- func RegisterSwaggerAPI(rtr *mux.Router)
- func SetAppLog(newLogger log.Logger)
- func SignCheckDeliver(t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, ...) (sdk.GasInfo, *sdk.Result, error)
- func TestAddr(addr string, bech string) (sdk.AccAddress, error)
- type App
- func New(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, ...) *App
- func Setup(isCheckTx bool, patchGenesis func(*App, GenesisState) GenesisState) *App
- func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *App
- func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, ...) *App
- func (app *App) AppCodec() codec.Codec
- func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock
- func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock
- func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs []string) (servertypes.ExportedApp, error)
- func (app *App) GetKey(storeKey string) *sdk.KVStoreKey
- func (app *App) GetMemKey(storeKey string) *sdk.MemoryStoreKey
- func (app *App) GetSubspace(moduleName string) paramstypes.Subspace
- func (app *App) GetTKey(storeKey string) *sdk.TransientStoreKey
- func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain
- func (app *App) InterfaceRegistry() types.InterfaceRegistry
- func (app *App) LegacyAmino() *codec.LegacyAmino
- func (app *App) LoadHeight(height int64) error
- func (app *App) ModuleAccountAddrs() map[string]bool
- func (app *App) Name() string
- func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig)
- func (app *App) RegisterTendermintService(clientCtx client.Context)
- func (app *App) RegisterTxService(clientCtx client.Context)
- type CosmosApp
- type EmptyAppOptions
- type EncodingConfig
- type GenerateAccountStrategy
- type GenesisState
Constants ¶
const ( BankModuleTotalSupply = "378604525462891000000000000" GravityModuleInitAmount = "378600525462891000000000000" )
Variables ¶
var ( // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string // 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{}, genutil.AppModuleBasic{}, bank.AppModuleBasic{}, capability.AppModuleBasic{}, staking.AppModuleBasic{}, mint.AppModuleBasic{}, distr.AppModuleBasic{}, gov.NewAppModuleBasic(getGovProposalHandlers()...), params.AppModuleBasic{}, crisis.AppModuleBasic{}, slashing.AppModuleBasic{}, ibc.AppModuleBasic{}, upgrade.AppModuleBasic{}, evidence.AppModuleBasic{}, transfer.AppModuleBasic{}, vesting.AppModuleBasic{}, gravity.AppModuleBasic{}, other.AppModuleBasic{}, crosschain.AppModuleBasic{}, bsc.AppModuleBasic{}, polygon.AppModuleBasic{}, tron.AppModuleBasic{}, evmv0.AppModuleBasic{}, feemarketv0.AppModuleBasic{}, evm.AppModuleBasic{}, feemarket.AppModuleBasic{}, erc20.AppModuleBasic{}, migrate.AppModuleBasic{}, ) )
var DefaultConsensusParams = &abci.ConsensusParams{ Block: &abci.BlockParams{ MaxBytes: 1048576, MaxGas: -1, }, Evidence: &tmproto.EvidenceParams{ MaxAgeNumBlocks: 1000000, MaxAgeDuration: 504 * time.Hour, MaxBytes: 100000, }, 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 *App, 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 *App, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress
AddTestAddrsIncremental constructs and returns accNum amount of accounts with an initial balance of accAmt in random order
func BeginBlockForks ¶
func CheckBalance ¶
CheckBalance checks the balance of an account.
func ConvertAddrsToValAddrs ¶
func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress
ConvertAddrsToValAddrs converts the provided addresses to ValAddress.
func CreateIncrementalAccounts ¶
func CreateIncrementalAccounts(accNum int) []sdk.AccAddress
CreateIncrementalAccounts is a strategy used by addTestAddrs() in order to generated addresses in ascending order.
func CreateTestPubKeys ¶
func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey
CreateTestPubKeys returns a total of numPubKeys public keys in ascending order.
func CustomConsensusParams ¶
func CustomConsensusParams() *tmproto.ConsensusParams
func GenSequenceOfTxs ¶
func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...cryptotypes.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 GenerateGenesisValidator ¶
func GenerateGenesisValidator(validatorNum int, initCoins sdk.Coins) (*tmtypes.ValidatorSet, authtypes.GenesisAccounts, []banktypes.Balance)
func NewDefAppGenesisByDenom ¶
func NewPubKeyFromHex ¶
func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey)
NewPubKeyFromHex returns a PubKey from a hex string.
func RegisterSwaggerAPI ¶ added in v1.1.2
RegisterSwaggerAPI registers swagger route with API Server
func SignCheckDeliver ¶
func SignCheckDeliver( t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.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.
Types ¶
type App ¶
type App struct {
*baseapp.BaseApp
// keepers
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper stakingkeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
MintKeeper mintkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper govkeeper.Keeper
CrisisKeeper crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration
GravityKeeper gravitykeeper.Keeper
CrosschainKeeper crosschainkeeper.RouterKeeper
BscKeeper crosschainkeeper.Keeper
PolygonKeeper crosschainkeeper.Keeper
TronKeeper crosschainkeeper.Keeper
// Ethermint keepers
EvmKeeperV0 *evmkeeperv0.Keeper
EvmKeeper *evmkeeper.Keeper
FeeMarketKeeperV0 feemarketkeeperv0.Keeper
FeeMarketKeeper feemarketkeeper.Keeper
Erc20Keeper erc20keeper.Keeper
MigrateKeeper migratekeeper.Keeper
// contains filtered or unexported fields
}
App 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 Setup ¶
func Setup(isCheckTx bool, patchGenesis func(*App, GenesisState) GenesisState) *App
Setup initializes a new SimApp. A Nop logger is set in SimApp.
func SetupWithGenesisAccounts ¶
func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *App
SetupWithGenesisAccounts initializes a new SimApp with the provided genesis accounts and possible balances.
func SetupWithGenesisValSet ¶
func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *App
SetupWithGenesisValSet initializes a new SimApp with a validator set and genesis accounts that also act as delegators. For simplicity, each validator is bonded with a delegation of one consensus engine unit (10^6) in the default token of the simapp from first genesis account. A Nop logger is set in SimApp.
func (*App) AppCodec ¶
AppCodec 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 (*App) BeginBlocker ¶
func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock
BeginBlocker application updates every begin block
func (*App) EndBlocker ¶
func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock
EndBlocker application updates every end block
func (*App) ExportAppStateAndValidators ¶
func (app *App) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs []string, ) (servertypes.ExportedApp, error)
ExportAppStateAndValidators exports the state of the application for a genesis file.
func (*App) GetKey ¶
func (app *App) 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 (*App) GetMemKey ¶
func (app *App) GetMemKey(storeKey string) *sdk.MemoryStoreKey
GetMemKey returns the MemStoreKey for the provided mem key.
NOTE: This is solely used for testing purposes.
func (*App) GetSubspace ¶
func (app *App) GetSubspace(moduleName string) paramstypes.Subspace
GetSubspace returns a param subspace for a given module name.
NOTE: This is solely to be used for testing purposes.
func (*App) GetTKey ¶
func (app *App) 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 (*App) InitChainer ¶
func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain
InitChainer application update at chain initialization
func (*App) InterfaceRegistry ¶
func (app *App) InterfaceRegistry() types.InterfaceRegistry
InterfaceRegistry returns InterfaceRegistry
func (*App) LegacyAmino ¶
func (app *App) LegacyAmino() *codec.LegacyAmino
LegacyAmino 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 (*App) LoadHeight ¶
LoadHeight loads a particular height
func (*App) ModuleAccountAddrs ¶
ModuleAccountAddrs returns all the app's module account addresses.
func (*App) RegisterAPIRoutes ¶
RegisterAPIRoutes registers all application module routes with the provided API server.
func (*App) RegisterTendermintService ¶
RegisterTendermintService implements the Application.RegisterTendermintService method.
func (*App) RegisterTxService ¶
RegisterTxService implements the Application.RegisterTxService method.
type CosmosApp ¶
type CosmosApp interface {
// Name The assigned name of the app.
Name() string
// LegacyAmino The application types codec.
// NOTE: This shoult be sealed before being returned.
LegacyAmino() *codec.LegacyAmino
// BeginBlocker Application updates every begin block.
BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock
// EndBlocker Application updates every end block.
EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock
// InitChainer Application update at chain (i.e app) initialization.
InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain
// LoadHeight Loads the app at a given height.
LoadHeight(height int64) error
// ExportAppStateAndValidators Exports the state of the application for a genesis file.
ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs []string) (types.ExportedApp, error)
// ModuleAccountAddrs All the registered module account addreses.
ModuleAccountAddrs() map[string]bool
}
CosmosApp 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 EncodingConfig ¶
type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}
EncodingConfig specifies the concrete encoding types to use for a given app. This is provided for compatibility between protobuf and amino implementations.
func MakeEncodingConfig ¶
func MakeEncodingConfig() EncodingConfig
MakeEncodingConfig creates an EncodingConfig for testing
type GenerateAccountStrategy ¶
type GenerateAccountStrategy func(int) []sdk.AccAddress
type GenesisState ¶
type GenesisState map[string]json.RawMessage
GenesisState 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 DefaultTestGenesis ¶
func DefaultTestGenesis(cdc codec.JSONCodec) GenesisState