testutil

package
v0.0.0-...-7b9cf15 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FundedAccountName = "whale"
	// use coin type 60 so we are compatible with accounts from `black 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 blackparams.EncodingConfig

	Auth      authtypes.QueryClient
	Bank      banktypes.QueryClient
	Community communitytypes.QueryClient
	Earn      earntypes.QueryClient
	Evm       evmtypes.QueryClient
	Tm        tmservice.ServiceClient
	Tx        txtypes.ServiceClient
	// 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) 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

	Black *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) BlackHomePath

func (suite *E2eTestSuite) BlackHomePath() string

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

func (*E2eTestSuite) FundBlackErc20Balance

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

func (*E2eTestSuite) GetErc20Balance

func (suite *E2eTestSuite) GetErc20Balance(address common.Address) *big.Int

func (*E2eTestSuite) InitBlackEvmData

func (suite *E2eTestSuite) InitBlackEvmData()

InitBlackEvmData 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) 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) SignAndBroadcastBlackTx

func (a *SigningAccount) SignAndBroadcastBlackTx(req util.BlackMsgRequest) util.BlackMsgResponse

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

func (*SigningAccount) SignAndBroadcastEvmTx

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

SignAndBroadcastEvmTx 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 black.configTemplate flag to be passed to kvtool, usually "master".
	// This allows one to change the base genesis used to start the chain.
	BlackConfigTemplate 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.
	BlackUpgradeName string
	// Height upgrade will be applied to the test chain, if upgrade is enabled.
	BlackUpgradeHeight int64
	// Tag of black docker image that will be upgraded to the current image before tests are run, if upgrade is enabled.
	BlackUpgradeBaseImageTag string

	// The contract address of a deployed ERC-20 token
	BlackErc20Address 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