testutil

package
v0.24.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FundedAccountName = "whale"
	// use coin type 60 so we are compatible with accounts from `kava add keys --eth <name>`
	// these accounts use the ethsecp256k1 signing algorithm that allows the signing client
	// to manage both sdk & evm txs.
	Bip44CoinType = 60

	IbcPort    = "transfer"
	IbcChannel = "channel-0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain struct {
	StakingDenom string
	ChainId      string

	EvmClient     *ethclient.Client
	ContractAddrs map[string]common.Address

	EncodingConfig kavaparams.EncodingConfig

	Auth      authtypes.QueryClient
	Bank      banktypes.QueryClient
	Committee committeetypes.QueryClient
	Community communitytypes.QueryClient
	Earn      earntypes.QueryClient
	Evm       evmtypes.QueryClient
	Evmutil   evmutiltypes.QueryClient
	Tm        tmservice.ServiceClient
	Tx        txtypes.ServiceClient
	Upgrade   upgradetypes.QueryClient
	// contains filtered or unexported fields
}

Chain wraps query clients & accounts for a network

func NewChain

func NewChain(t *testing.T, details *runner.ChainDetails, fundedAccountMnemonic string) (*Chain, error)

NewChain creates the query clients & signing account management for a chain run on a set of ports. A signing client for the fundedAccountMnemonic is initialized. This account is referred to in the code as "whale" and it is used to supply funds to all new accounts.

func (*Chain) AddNewSigningAccount

func (chain *Chain) AddNewSigningAccount(name string, hdPath *hd.BIP44Params, chainId, mnemonic string) *SigningAccount

AddNewSigningAccount sets up a new account with a signer for SDK and EVM transactions.

func (*Chain) GetAccount

func (chain *Chain) GetAccount(name string) *SigningAccount

GetAccount returns the account with the given name or fails.

func (*Chain) GetErc20Balance added in v0.24.0

func (chain *Chain) GetErc20Balance(contract, address common.Address) *big.Int

func (*Chain) GetModuleBalances added in v0.24.0

func (chain *Chain) GetModuleBalances(moduleName string) sdk.Coins

GetModuleBalances returns the balance of a requested module account

func (*Chain) NewFundedAccount

func (chain *Chain) NewFundedAccount(name string, funds sdk.Coins) *SigningAccount

NewFundedAccount creates a SigningAccount for a random account & funds the account from the whale.

func (*Chain) QuerySdkForBalances

func (chain *Chain) QuerySdkForBalances(addr sdk.AccAddress) sdk.Coins

QuerySdkForBalances gets the balance of a particular address on this Chain.

func (*Chain) Shutdown

func (chain *Chain) Shutdown()

Shutdown performs closes all the account request channels for this chain.

type E2eTestSuite

type E2eTestSuite struct {
	suite.Suite

	Kava *Chain
	Ibc  *Chain

	UpgradeHeight        int64
	DeployedErc20Address common.Address
	// contains filtered or unexported fields
}

func (*E2eTestSuite) BigIntsEqual

func (suite *E2eTestSuite) BigIntsEqual(expected *big.Int, actual *big.Int, msg string)

BigIntsEqual is a helper method for comparing the equality of two big ints

func (*E2eTestSuite) FundKavaErc20Balance

func (suite *E2eTestSuite) FundKavaErc20Balance(toAddress common.Address, amount *big.Int) EvmTxResponse

func (*E2eTestSuite) InitKavaEvmData

func (suite *E2eTestSuite) InitKavaEvmData()

InitKavaEvmData is run after the chain is running, but before the tests are run. It is used to initialize some EVM state, such as deploying contracts.

func (*E2eTestSuite) KavaHomePath

func (suite *E2eTestSuite) KavaHomePath() string

KavaHomePath returns the OS-specific filepath for the kava home directory Assumes network is running with kvtool installed from the sub-repository in tests/e2e/kvtool

func (*E2eTestSuite) NewEip712TxBuilder

func (suite *E2eTestSuite) NewEip712TxBuilder(
	acc *SigningAccount, chain *Chain, gas uint64, gasAmount sdk.Coins, msgs []sdk.Msg, memo string,
) client.TxBuilder

func (*E2eTestSuite) SetupSuite

func (suite *E2eTestSuite) SetupSuite()

func (*E2eTestSuite) SkipIfIbcDisabled

func (suite *E2eTestSuite) SkipIfIbcDisabled()

func (*E2eTestSuite) SkipIfUpgradeDisabled

func (suite *E2eTestSuite) SkipIfUpgradeDisabled()

func (*E2eTestSuite) TearDownSuite

func (suite *E2eTestSuite) TearDownSuite()

type EvmTxResponse

type EvmTxResponse struct {
	util.EvmTxResponse
	Receipt *ethtypes.Receipt
}

EvmTxResponse is util.EvmTxResponse that also includes the Receipt, if available

type SigningAccount

type SigningAccount struct {
	EvmAuth *bind.TransactOpts

	EvmAddress common.Address
	SdkAddress sdk.AccAddress
	// contains filtered or unexported fields
}

func (*SigningAccount) NextNonce added in v0.24.0

func (a *SigningAccount) NextNonce() (uint64, error)

GetNonce fetches the next nonce / sequence number for the account.

func (*SigningAccount) SignAndBroadcastEvmTx

func (a *SigningAccount) SignAndBroadcastEvmTx(req util.EvmTxRequest) EvmTxResponse

SignAndBroadcastEvmTx sends a request to the signer and awaits its response.

func (*SigningAccount) SignAndBroadcastKavaTx

func (a *SigningAccount) SignAndBroadcastKavaTx(req util.KavaMsgRequest) util.KavaMsgResponse

SignAndBroadcastKavaTx sends a request to the signer and awaits its response.

func (*SigningAccount) SignRawEvmData

func (a *SigningAccount) SignRawEvmData(msg []byte) ([]byte, types.PubKey, error)

type SuiteConfig

type SuiteConfig struct {
	// A funded account used to fnd all other accounts.
	FundedAccountMnemonic string
	// The kava.configTemplate flag to be passed to kvtool, usually "master".
	// This allows one to change the base genesis used to start the chain.
	KavaConfigTemplate string
	// Whether or not to start an IBC chain. Use `suite.SkipIfIbcDisabled()` in IBC tests in IBC tests.
	IncludeIbcTests bool

	// Whether or not to run a chain upgrade & run post-upgrade tests. Use `suite.SkipIfUpgradeDisabled()` in post-upgrade tests.
	IncludeAutomatedUpgrade bool
	// Name of the upgrade, if upgrade is enabled.
	KavaUpgradeName string
	// Height upgrade will be applied to the test chain, if upgrade is enabled.
	KavaUpgradeHeight int64
	// Tag of kava docker image that will be upgraded to the current image before tests are run, if upgrade is enabled.
	KavaUpgradeBaseImageTag string

	// The contract address of a deployed ERC-20 token
	KavaErc20Address string

	// When true, the chains will remain running after tests complete (pass or fail)
	SkipShutdown bool
}

func ParseSuiteConfig

func ParseSuiteConfig() SuiteConfig

Jump to

Keyboard shortcuts

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