simapp

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2020 License: Apache-2.0 Imports: 53 Imported by: 0

README

SimApp

This directory is based on a copy from here.

Mainly it aims to a test for cross module.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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{},
		genutil.AppModuleBasic{},
		bank.AppModuleBasic{},
		staking.AppModuleBasic{},
		mint.AppModuleBasic{},
		distr.AppModuleBasic{},
		gov.NewAppModuleBasic(
			paramsclient.ProposalHandler, distr.ProposalHandler, upgradeclient.ProposalHandler,
		),
		params.AppModuleBasic{},
		crisis.AppModuleBasic{},
		slashing.AppModuleBasic{},
		ibc.AppModuleBasic{},
		upgrade.AppModuleBasic{},
		evidence.AppModuleBasic{},
		transfer.AppModuleBasic{},
		cross.AppModuleBasic{},
		contract.AppModuleBasic{},
	)

	DefaultContractHandlerProvider = simappcontract.CounterContractHandlerProvider
)
View Source
var DefaultConsensusParams = &abci.ConsensusParams{
	Block: &abci.BlockParams{
		MaxBytes: 200000,
		MaxGas:   2000000,
	},
	Evidence: &abci.EvidenceParams{
		MaxAgeNumBlocks: 302400,
		MaxAgeDuration:  1814400,
	},
	Validator: &abci.ValidatorParams{
		PubKeyTypes: []string{
			tmtypes.ABCIPubKeyTypeEd25519,
			tmtypes.ABCIPubKeyTypeSecp256k1,
		},
	},
}

DefaultConsensusParams defines the default Tendermint consensus params used in SimApp testing.

Functions

func AddTestAddrs

func AddTestAddrs(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 AddTestAddrsFromPubKeys

func AddTestAddrsFromPubKeys(app *SimApp, ctx sdk.Context, pubKeys []crypto.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 CheckBalance

func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, balances sdk.Coins)

CheckBalance checks the balance of an account.

func ConvertAddrsToValAddrs

func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress

ConvertAddrsToValAddrs converts the provided addresses to ValAddress.

func CreateTestPubKeys

func CreateTestPubKeys(numPubKeys int) []crypto.PubKey

CreateTestPubKeys returns a total of numPubKeys public keys in ascending order.

func DefaultAnteHandlerProvider

func DefaultAnteHandlerProvider(app *SimApp) sdk.AnteHandler

func DefaultChannelResolverProvider added in v0.0.6

func DefaultChannelResolverProvider() cross.ChannelResolver

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

func GetMaccPerms() map[string][]string

GetMaccPerms returns a copy of the module account permissions

func NewPubKeyFromHex

func NewPubKeyFromHex(pk string) (res crypto.PubKey)

NewPubKeyFromHex returns a PubKey from a hex string.

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 TestAddr

func TestAddr(addr string, bech string) (sdk.AccAddress, error)

Types

type AnteHandlerProvider

type AnteHandlerProvider = func(*SimApp) sdk.AnteHandler

type ChannelResolverProvider added in v0.0.6

type ChannelResolverProvider = func() cross.ChannelResolver

type GenerateAccountStrategy

type GenerateAccountStrategy func(int) []sdk.AccAddress

type SimApp

type SimApp struct {
	*bam.BaseApp

	// keepers
	AccountKeeper    auth.AccountKeeper
	BankKeeper       bank.Keeper
	CapabilityKeeper *capability.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
	IBCKeeper        *ibc.Keeper
	EvidenceKeeper   evidence.Keeper
	TransferKeeper   transfer.Keeper
	CrossKeeper      cross.Keeper
	ContractKeeper   contract.Keeper

	// make scoped keepers public for test purposes
	ScopedIBCKeeper      capability.ScopedKeeper
	ScopedTransferKeeper capability.ScopedKeeper
	ScopedCrossKeeper    capability.ScopedKeeper
	ContractHandler      cross.ContractHandler
	// 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,
	homePath string, invCheckPeriod uint,
	contractHandlerProvider ContractHandlerProvider, channelResolverProvider ChannelResolverProvider, anteHandlerProvider AnteHandlerProvider,
	packetMiddleware types.PacketMiddleware,
	baseAppOptions ...func(*bam.BaseApp),
) *SimApp

NewSimApp returns a reference to an initialized SimApp.

func Setup

func Setup(isCheckTx bool) *SimApp

Setup initializes a new SimApp. A Nop logger is set in SimApp.

func SetupWithGenesisAccounts

func SetupWithGenesisAccounts(chainID string, contractHandlerProvider ContractHandlerProvider, channelResolverProvider ChannelResolverProvider, anteHandlerProvider AnteHandlerProvider, packetMiddleware types.PacketMiddleware, genAccs []authexported.GenesisAccount, balances ...bank.Balance) *SimApp

SetupWithGenesisAccounts initializes a new SimApp with the provided genesis accounts and possible balances.

func SetupWithOptions added in v0.0.6

func SetupWithOptions(isCheckTx bool, contractHandlerProvider ContractHandlerProvider, channelResolverProvider ChannelResolverProvider, anteHandlerProvider AnteHandlerProvider, packetMiddleware types.PacketMiddleware) *SimApp

func (*SimApp) BeginBlocker

func (app *SimApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock

BeginBlocker application updates every begin block

func (*SimApp) BlacklistedAccAddrs

func (app *SimApp) BlacklistedAccAddrs() map[string]bool

BlacklistedAccAddrs returns all the app's module account addresses black listed for receiving tokens.

func (*SimApp) Codec

func (app *SimApp) Codec() *codec.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, cp *abci.ConsensusParams, 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) GetMemKey

func (app *SimApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey

GetMemKey returns the MemStoreKey for the provided mem key.

NOTE: This is solely used for testing purposes.

func (*SimApp) GetSubspace

func (app *SimApp) GetSubspace(moduleName string) params.Subspace

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

func (app *SimApp) LoadHeight(height int64) error

LoadHeight loads a particular height

func (*SimApp) ModuleAccountAddrs

func (app *SimApp) ModuleAccountAddrs() map[string]bool

ModuleAccountAddrs returns all the app's module account addresses.

func (*SimApp) Name

func (app *SimApp) Name() string

Name returns the name of the App

func (*SimApp) SimulationManager

func (app *SimApp) SimulationManager() *module.SimulationManager

SimulationManager implements the SimulationApp interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL