runner

package
v0.0.0-...-1929ff6 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 78 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ZRC20InitialSupply is the initial supply of the ZRC20 token
	ZRC20SOLInitialSupply = 100000000

	// SolanaPDAInitialBalance is the initial balance (in lamports) of the gateway PDA account
	SolanaPDAInitialBalance = 1447680
)
View Source
const (
	EnvKeyLocalnetMode = "LOCALNET_MODE"

	LocalnetModeUpgrade = "upgrade"
)

Important ENV

View Source
const (
	ContractsConfigFile = "contracts.toml"
)

Variables

View Source
var EmissionsPoolFunding = big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(2e7))

EmissionsPoolFunding represents the amount of ZETA to fund the emissions pool with This is the same value as used originally on mainnet (20M ZETA)

Functions

This section is empty.

Types

type AccountBalances

type AccountBalances struct {
	ZetaETH   *big.Int
	ZetaZETA  *big.Int
	ZetaWZETA *big.Int
	ZetaERC20 *big.Int
	ZetaBTC   *big.Int
	ZetaSOL   *big.Int
	EvmETH    *big.Int
	EvmZETA   *big.Int
	EvmERC20  *big.Int
	BtcBTC    string
}

AccountBalances is a struct that contains the balances of the accounts used in the E2E test

type AccountBalancesDiff

type AccountBalancesDiff struct {
	ETH   *big.Int
	ZETA  *big.Int
	ERC20 *big.Int
}

AccountBalancesDiff is a struct that contains the difference in the balances of the accounts used in the E2E test

func GetAccountBalancesDiff

func GetAccountBalancesDiff(balancesBefore, balancesAfter AccountBalances) AccountBalancesDiff

GetAccountBalancesDiff returns the difference in the account balances of the accounts used in the E2E test

type Amount

type Amount struct {
	Denom  string `json:"denom"`
	Amount string `json:"amount"`
}

type ArgDefinition

type ArgDefinition struct {
	Description  string
	DefaultValue string
}

ArgDefinition defines a structure for holding an argument's description along with it's default value.

type Clients

type Clients struct {
	Zetacore zetacore_rpc.Clients

	// the RPC clients for external chains in the localnet
	BtcRPC  *rpcclient.Client
	Solana  *rpc.Client
	Evm     *ethclient.Client
	EvmAuth *bind.TransactOpts

	// the RPC clients for ZetaChain
	Zevm     *ethclient.Client
	ZevmAuth *bind.TransactOpts
}

Clients contains all the RPC clients and gRPC clients for E2E tests

type E2ERunner

type E2ERunner struct {
	// accounts
	Account               config.Account
	TSSAddress            ethcommon.Address
	BTCTSSAddress         btcutil.Address
	BTCDeployerAddress    *btcutil.AddressWitnessPubKeyHash
	SolanaDeployerAddress solana.PublicKey

	// all clients.
	// a reference to this type is required to enable creating a new E2ERunner.
	Clients Clients

	// rpc clients
	ZEVMClient   *ethclient.Client
	EVMClient    *ethclient.Client
	BtcRPCClient *rpcclient.Client
	SolanaClient *rpc.Client

	// zetacored grpc clients
	AuthorityClient   authoritytypes.QueryClient
	CctxClient        crosschaintypes.QueryClient
	FungibleClient    fungibletypes.QueryClient
	AuthClient        authtypes.QueryClient
	BankClient        banktypes.QueryClient
	StakingClient     stakingtypes.QueryClient
	ObserverClient    observertypes.QueryClient
	LightclientClient lightclienttypes.QueryClient

	// optional zeta (cosmos) client
	// typically only in test runners that need it
	// (like admin tests)
	ZetaTxServer *txserver.ZetaTxServer

	// evm auth
	EVMAuth  *bind.TransactOpts
	ZEVMAuth *bind.TransactOpts

	// programs on Solana
	GatewayProgram solana.PublicKey

	// contracts evm
	ZetaEthAddr      ethcommon.Address
	ZetaEth          *zetaeth.ZetaEth
	ConnectorEthAddr ethcommon.Address
	ConnectorEth     *zetaconnectoreth.ZetaConnectorEth
	ERC20CustodyAddr ethcommon.Address
	ERC20Custody     *erc20custody.ERC20Custody
	ERC20Addr        ethcommon.Address
	ERC20            *erc20.ERC20
	EvmTestDAppAddr  ethcommon.Address

	// contracts zevm
	ERC20ZRC20Addr       ethcommon.Address
	ERC20ZRC20           *zrc20.ZRC20
	ETHZRC20Addr         ethcommon.Address
	ETHZRC20             *zrc20.ZRC20
	BTCZRC20Addr         ethcommon.Address
	BTCZRC20             *zrc20.ZRC20
	SOLZRC20Addr         ethcommon.Address
	SOLZRC20             *zrc20.ZRC20
	UniswapV2FactoryAddr ethcommon.Address
	UniswapV2Factory     *uniswapv2factory.UniswapV2Factory
	UniswapV2RouterAddr  ethcommon.Address
	UniswapV2Router      *uniswapv2router.UniswapV2Router02
	ConnectorZEVMAddr    ethcommon.Address
	ConnectorZEVM        *connectorzevm.ZetaConnectorZEVM
	WZetaAddr            ethcommon.Address
	WZeta                *wzeta.WETH9
	ZEVMSwapAppAddr      ethcommon.Address
	ZEVMSwapApp          *zevmswap.ZEVMSwapApp
	ContextAppAddr       ethcommon.Address
	ContextApp           *contextapp.ContextApp
	SystemContractAddr   ethcommon.Address
	SystemContract       *systemcontract.SystemContract
	ZevmTestDAppAddr     ethcommon.Address

	// config
	CctxTimeout    time.Duration
	ReceiptTimeout time.Duration

	// other
	Name          string
	Ctx           context.Context
	CtxCancel     context.CancelFunc
	Logger        *Logger
	BitcoinParams *chaincfg.Params

	// evm v2
	GatewayEVMAddr     ethcommon.Address
	GatewayEVM         *gatewayevm.GatewayEVM
	ERC20CustodyV2Addr ethcommon.Address
	ERC20CustodyV2     *erc20custodyv2.ERC20Custody
	TestDAppV2EVMAddr  ethcommon.Address
	TestDAppV2EVM      *testdappv2.TestDAppV2

	// zevm v2
	GatewayZEVMAddr    ethcommon.Address
	GatewayZEVM        *gatewayzevm.GatewayZEVM
	TestDAppV2ZEVMAddr ethcommon.Address
	TestDAppV2ZEVM     *testdappv2.TestDAppV2
	// contains filtered or unexported fields
}

E2ERunner stores all the clients and addresses needed for E2E test Exposes a method to run E2E test It also provides some helper functions

func NewE2ERunner

func NewE2ERunner(
	ctx context.Context,
	name string,
	ctxCancel context.CancelFunc,
	account config.Account,
	clients Clients,
	logger *Logger,
	opts ...E2ERunnerOption,
) *E2ERunner

func (*E2ERunner) AddLiquidityERC20

func (r *E2ERunner) AddLiquidityERC20(amountZETA, amountERC20 *big.Int)

AddLiquidityERC20 adds liquidity token to the uniswap pool ZETA/ERC20 we use the provided amount of ZETA and ERC20 to add liquidity as wanted amount 0 is used for the minimum amount of ZETA and ERC20

func (*E2ERunner) AddLiquidityETH

func (r *E2ERunner) AddLiquidityETH(amountZETA, amountETH *big.Int)

AddLiquidityETH adds liquidity token to the uniswap pool ZETA/ETH we use the provided amount of ZETA and ETH to add liquidity as wanted amount 0 is used for the minimum amount of ZETA and ETH

func (*E2ERunner) AddTSSToNode

func (r *E2ERunner) AddTSSToNode()

func (*E2ERunner) AnvilMineBlocks

func (r *E2ERunner) AnvilMineBlocks(url string, blockTime int) (func(), error)

AnvilMineBlocks mines blocks on Anvil localnet the block time is provided in seconds the method returns a function to stop the mining

func (*E2ERunner) ApproveERC20OnEVM

func (r *E2ERunner) ApproveERC20OnEVM(allowed ethcommon.Address)

ApproveERC20OnEVM approves ERC20 on EVM to a specific address check if allowance is zero before calling this method allow a high amount to avoid multiple approvals

func (*E2ERunner) ApproveERC20ZRC20

func (r *E2ERunner) ApproveERC20ZRC20(allowed ethcommon.Address)

ApproveERC20ZRC20 approves ERC20 ZRC20 on EVM to a specific address check if allowance is zero before calling this method allow a high amount to avoid multiple approvals

func (*E2ERunner) ApproveETHZRC20

func (r *E2ERunner) ApproveETHZRC20(allowed ethcommon.Address)

ApproveETHZRC20 approves ETH ZRC20 on EVM to a specific address check if allowance is zero before calling this method allow a high amount to avoid multiple approvals

func (*E2ERunner) AssertTestDAppEVMCalled

func (r *E2ERunner) AssertTestDAppEVMCalled(expectedCalled bool, message string, amount *big.Int)

AssertTestDAppEVMCalled is a function that asserts the values of the test dapp on the external EVM

func (*E2ERunner) AssertTestDAppZEVMCalled

func (r *E2ERunner) AssertTestDAppZEVMCalled(expectedCalled bool, message string, amount *big.Int)

AssertTestDAppZEVMCalled is a function that asserts the values of the test dapp on the ZEVM this function uses TestDAppV2 for the assertions, in the future we should only use this contracts for all tests https://github.com/zeta-chain/node/issues/2655

func (*E2ERunner) BroadcastTxSync

func (r *E2ERunner) BroadcastTxSync(tx *solana.Transaction) (solana.Signature, *rpc.GetTransactionResult)

BroadcastTxSync broadcasts a transaction and waits for it to be finalized

func (*E2ERunner) CheckBtcTSSBalance

func (r *E2ERunner) CheckBtcTSSBalance() error

func (*E2ERunner) CheckSolanaTSSBalance

func (r *E2ERunner) CheckSolanaTSSBalance() error

CheckSolanaTSSBalance compares the gateway PDA balance with the total supply of the SOL ZRC20 on ZetaChain

func (*E2ERunner) CheckZRC20ReserveAndSupply

func (r *E2ERunner) CheckZRC20ReserveAndSupply() error

func (*E2ERunner) ComputePdaAddress

func (r *E2ERunner) ComputePdaAddress() solana.PublicKey

ComputePdaAddress computes the PDA address for the gateway program

func (*E2ERunner) CopyAddressesFrom

func (r *E2ERunner) CopyAddressesFrom(other *E2ERunner) (err error)

CopyAddressesFrom copies addresses from another E2ETestRunner that initialized the contracts

func (*E2ERunner) CreateDepositInstruction

func (r *E2ERunner) CreateDepositInstruction(
	signer solana.PublicKey,
	receiver ethcommon.Address,
	data []byte,
	amount uint64,
) solana.Instruction

CreateDepositInstruction creates a 'deposit' instruction

func (*E2ERunner) CreateSignedTransaction

func (r *E2ERunner) CreateSignedTransaction(
	instructions []solana.Instruction,
	privateKey solana.PrivateKey,
) *solana.Transaction

CreateSignedTransaction creates a signed transaction from instructions

func (*E2ERunner) DepositAndApproveWZeta

func (r *E2ERunner) DepositAndApproveWZeta(amount *big.Int)

DepositAndApproveWZeta deposits and approves WZETA on ZetaChain from the ZETA smart contract on ZEVM

func (*E2ERunner) DepositBTC

func (r *E2ERunner) DepositBTC()

DepositBTC deposits BTC on ZetaChain

func (*E2ERunner) DepositBTCWithAmount

func (r *E2ERunner) DepositBTCWithAmount(amount float64) *chainhash.Hash

DepositBTCWithAmount deposits BTC on ZetaChain with a specific amount

func (*E2ERunner) DepositERC20

func (r *E2ERunner) DepositERC20() ethcommon.Hash

func (*E2ERunner) DepositERC20WithAmountAndMessage

func (r *E2ERunner) DepositERC20WithAmountAndMessage(to ethcommon.Address, amount *big.Int, msg []byte) ethcommon.Hash

func (*E2ERunner) DepositEther

func (r *E2ERunner) DepositEther() ethcommon.Hash

DepositEther sends Ethers into ZEVM

func (*E2ERunner) DepositEtherWithAmount

func (r *E2ERunner) DepositEtherWithAmount(amount *big.Int) ethcommon.Hash

DepositEtherWithAmount sends Ethers into ZEVM

func (*E2ERunner) DepositZeta

func (r *E2ERunner) DepositZeta() ethcommon.Hash

DepositZeta deposits ZETA on ZetaChain from the ZETA smart contract on EVM

func (*E2ERunner) DepositZetaWithAmount

func (r *E2ERunner) DepositZetaWithAmount(to ethcommon.Address, amount *big.Int) ethcommon.Hash

DepositZetaWithAmount deposits ZETA on ZetaChain from the ZETA smart contract on EVM with the specified amount

func (*E2ERunner) EVMAddress

func (r *E2ERunner) EVMAddress() ethcommon.Address

EVMAddress is shorthand to get the EVM address of the account

func (*E2ERunner) EnableHeaderVerification

func (r *E2ERunner) EnableHeaderVerification(chainIDList []int64) error

EnableHeaderVerification enables the header verification for the given chain IDs

func (*E2ERunner) EncodeERC20Call

func (r *E2ERunner) EncodeERC20Call(erc20Addr ethcommon.Address, amount *big.Int, message string) []byte

EncodeERC20Call encodes the payload for the erc20Call function

func (*E2ERunner) EncodeERC20CallRevert

func (r *E2ERunner) EncodeERC20CallRevert(erc20Addr ethcommon.Address, amount *big.Int) []byte

EncodeERC20CallRevert encodes the payload for the erc20Call function that reverts

func (*E2ERunner) EncodeGasCall

func (r *E2ERunner) EncodeGasCall(message string) []byte

EncodeGasCall encodes the payload for the gasCall function

func (*E2ERunner) EncodeGasCallRevert

func (r *E2ERunner) EncodeGasCallRevert() []byte

EncodeGasCallRevert encodes the payload for the gasCall function that reverts

func (*E2ERunner) EncodeSimpleCall

func (r *E2ERunner) EncodeSimpleCall(message string) []byte

EncodeSimpleCall encodes the payload for the simpleCall function

func (*E2ERunner) EnsureNoTrackers

func (r *E2ERunner) EnsureNoTrackers()

EnsureNoTrackers ensures that there are no trackers left on zetacore

func (*E2ERunner) EnsureZeroBalanceAddressZEVM

func (r *E2ERunner) EnsureZeroBalanceAddressZEVM()

EnsureZeroBalanceAddressZEVM ensures that the balance of the address is zero in the ZEVM

func (*E2ERunner) Errorf

func (r *E2ERunner) Errorf(format string, args ...any)

Errorf logs an error message. Mimics the behavior of testing.T.Errorf

func (*E2ERunner) FailNow

func (r *E2ERunner) FailNow()

FailNow implemented to mimic the behavior of testing.T.FailNow

func (*E2ERunner) FundEmissionsPool

func (r *E2ERunner) FundEmissionsPool() error

FundEmissionsPool funds the emissions pool on ZetaChain with the same value as used originally on mainnet (20M ZETA)

func (*E2ERunner) GenerateNetworkReport

func (r *E2ERunner) GenerateNetworkReport() (NetworkReport, error)

GenerateNetworkReport generates a report for the network used after running e2e tests

func (*E2ERunner) GenerateToAddressIfLocalBitcoin

func (r *E2ERunner) GenerateToAddressIfLocalBitcoin(
	numBlocks int64,
	address btcutil.Address,
) ([]*chainhash.Hash, error)

GenerateToAddressIfLocalBitcoin generates blocks to an address if the runner is interacting with a local bitcoin network

func (*E2ERunner) GetAccountBalances

func (r *E2ERunner) GetAccountBalances(skipBTC bool) (AccountBalances, error)

GetAccountBalances returns the account balances of the accounts used in the E2E test

func (*E2ERunner) GetBitcoinBalance

func (r *E2ERunner) GetBitcoinBalance() (string, error)

GetBitcoinBalance returns the spendable BTC balance of the BTC address

func (*E2ERunner) GetBitcoinBalanceByAddress

func (r *E2ERunner) GetBitcoinBalanceByAddress(address btcutil.Address) (btcutil.Amount, error)

GetBitcoinBalanceByAddress get btc balance by address.

func (*E2ERunner) GetBitcoinChainID

func (r *E2ERunner) GetBitcoinChainID() int64

GetBitcoinChainID gets the bitcoin chain ID from the network params

func (*E2ERunner) GetBtcAddress

func (r *E2ERunner) GetBtcAddress() (string, string, error)

GetBtcAddress returns the BTC address of the deployer from its EVM private key

func (*E2ERunner) GetE2ETestsToRunByConfig

func (r *E2ERunner) GetE2ETestsToRunByConfig(
	availableTests []E2ETest,
	testConfigs []E2ETestRunConfig,
) ([]E2ETest, error)

GetE2ETestsToRunByConfig prepares a list of E2ETests to run based on provided test names and their corresponding arguments

func (*E2ERunner) GetE2ETestsToRunByName

func (r *E2ERunner) GetE2ETestsToRunByName(availableTests []E2ETest, testNames ...string) ([]E2ETest, error)

GetE2ETestsToRunByName prepares a list of E2ETests to run based on given test names without arguments

func (*E2ERunner) GetTop20UTXOsForTssAddress

func (r *E2ERunner) GetTop20UTXOsForTssAddress() ([]btcjson.ListUnspentResult, error)

GetTop20UTXOsForTssAddress returns the top 20 UTXOs for the TSS address. Top 20 utxos should be used for TSS migration, as we can only migrate at max 20 utxos at a time.

func (*E2ERunner) IsLocalBitcoin

func (r *E2ERunner) IsLocalBitcoin() bool

IsLocalBitcoin returns true if the runner is running on a local bitcoin network

func (*E2ERunner) IsRunningUpgrade

func (r *E2ERunner) IsRunningUpgrade() bool

IsRunningUpgrade returns true if the test is running an upgrade test suite.

func (*E2ERunner) ListDeployerUTXOs

func (r *E2ERunner) ListDeployerUTXOs() ([]btcjson.ListUnspentResult, error)

ListDeployerUTXOs list the deployer's UTXOs

func (*E2ERunner) Lock

func (r *E2ERunner) Lock()

Lock locks the mutex

func (*E2ERunner) MineBlocksIfLocalBitcoin

func (r *E2ERunner) MineBlocksIfLocalBitcoin() func()

MineBlocksIfLocalBitcoin mines blocks on the local BTC chain at a rate of 1 blocks every 5 seconds and returns a channel that can be used to stop the mining If the chain is not local, the function does nothing

func (*E2ERunner) MintERC20OnEvm

func (r *E2ERunner) MintERC20OnEvm(amountERC20 int64)

MintERC20OnEvm mints ERC20 on EVM amount is a multiple of 1e18

func (*E2ERunner) PrintAccountBalances

func (r *E2ERunner) PrintAccountBalances(balances AccountBalances)

PrintAccountBalances shows the account balances of the accounts used in the E2E test Note: USDT is mentioned as erc20 here because we want to show the balance of any erc20 contract

func (*E2ERunner) PrintContractAddresses

func (r *E2ERunner) PrintContractAddresses()

PrintContractAddresses prints the addresses of the contracts the printed contracts are grouped in a zevm and evm section there is a padding used to print the addresses at the same position

func (*E2ERunner) PrintNetworkReport

func (r *E2ERunner) PrintNetworkReport(nr NetworkReport)

PrintNetworkReport prints the network report

func (*E2ERunner) PrintTestReports

func (r *E2ERunner) PrintTestReports(tr TestReports)

PrintTestReports prints the test reports

func (*E2ERunner) PrintTotalDiff

func (r *E2ERunner) PrintTotalDiff(accoutBalancesDiff AccountBalancesDiff)

PrintTotalDiff shows the difference in the account balances of the accounts used in the e2e test from two balances structs

func (*E2ERunner) RunE2ETest

func (r *E2ERunner) RunE2ETest(e2eTest E2ETest, checkAccounting bool) error

RunE2ETest runs a e2e test

func (*E2ERunner) RunE2ETests

func (r *E2ERunner) RunE2ETests(e2eTests []E2ETest) (err error)

RunE2ETests runs a list of e2e tests

func (*E2ERunner) RunE2ETestsIntoReport

func (r *E2ERunner) RunE2ETestsIntoReport(e2eTests []E2ETest) (TestReports, error)

RunE2ETestsIntoReport runs a list of e2e tests by name in a list of e2e tests and returns a report The function doesn't return an error, it returns a report with the error

func (*E2ERunner) RunV2Migration

func (r *E2ERunner) RunV2Migration()

RunV2Migration runs the process for the v2 migration

func (*E2ERunner) SOLDepositAndCall

func (r *E2ERunner) SOLDepositAndCall(
	signerPrivKey *solana.PrivateKey,
	receiver ethcommon.Address,
	amount *big.Int,
	data []byte,
) solana.Signature

SOLDepositAndCall deposits an amount of ZRC20 SOL tokens (in lamports) and calls a contract (if data is provided)

func (*E2ERunner) SendERC20OnEvm

func (r *E2ERunner) SendERC20OnEvm(address ethcommon.Address, amountERC20 int64) *ethtypes.Transaction

SendERC20OnEvm sends ERC20 to an address on EVM this allows the ERC20 contract deployer to funds other accounts on EVM amountERC20 is a multiple of 1e18

func (*E2ERunner) SendEther

func (r *E2ERunner) SendEther(_ ethcommon.Address, value *big.Int, data []byte) (*ethtypes.Transaction, error)

SendEther sends ethers to the TSS on EVM

func (*E2ERunner) SendToTSSFromDeployerToDeposit

func (r *E2ERunner) SendToTSSFromDeployerToDeposit(amount float64, inputUTXOs []btcjson.ListUnspentResult) (
	*chainhash.Hash,
	error,
)

func (*E2ERunner) SendToTSSFromDeployerWithMemo

func (r *E2ERunner) SendToTSSFromDeployerWithMemo(
	amount float64,
	inputUTXOs []btcjson.ListUnspentResult,
	memo []byte,
) (*chainhash.Hash, error)

func (*E2ERunner) SendZetaOnEvm

func (r *E2ERunner) SendZetaOnEvm(address ethcommon.Address, zetaAmount int64) *ethtypes.Transaction

SendZetaOnEvm sends ZETA to an address on EVM this allows the ZETA contract deployer to funds other accounts on EVM

func (*E2ERunner) SetBtcAddress

func (r *E2ERunner) SetBtcAddress(name string, rescan bool)

SetBtcAddress imports the deployer's private key into the Bitcoin node

func (*E2ERunner) SetEVMContractsFromConfig

func (r *E2ERunner) SetEVMContractsFromConfig()

SetEVMContractsFromConfig set EVM contracts for e2e test from the config

func (*E2ERunner) SetSolanaContracts

func (r *E2ERunner) SetSolanaContracts(deployerPrivateKey string)

SetSolanaContracts set Solana contracts

func (*E2ERunner) SetTSSAddresses

func (r *E2ERunner) SetTSSAddresses() error

SetTSSAddresses set TSS addresses from information queried from ZetaChain

func (*E2ERunner) SetZEVMContractsV2

func (r *E2ERunner) SetZEVMContractsV2()

SetZEVMContractsV2 set contracts for the ZEVM

func (*E2ERunner) SetZEVMSystemContracts

func (r *E2ERunner) SetZEVMSystemContracts()

SetZEVMSystemContracts set system contracts for the ZEVM

func (*E2ERunner) SetZEVMZRC20s

func (r *E2ERunner) SetZEVMZRC20s()

SetZEVMZRC20s set ZRC20 for the ZEVM

func (*E2ERunner) SetupBTCZRC20

func (r *E2ERunner) SetupBTCZRC20()

SetupBTCZRC20 sets up the BTC ZRC20 in the runner from the values queried from the chain

func (*E2ERunner) SetupBitcoinAccount

func (r *E2ERunner) SetupBitcoinAccount(initNetwork bool)

func (*E2ERunner) SetupETHZRC20

func (r *E2ERunner) SetupETHZRC20()

SetupETHZRC20 sets up the ETH ZRC20 in the runner from the values queried from the chain

func (*E2ERunner) SetupEVM

func (r *E2ERunner) SetupEVM(contractsDeployed bool, whitelistERC20 bool)

SetupEVM setup contracts on EVM for e2e test

func (*E2ERunner) SetupEVMV2

func (r *E2ERunner) SetupEVMV2()

SetupEVMV2 setup contracts on EVM with v2 contracts

func (*E2ERunner) SetupSOLZRC20

func (r *E2ERunner) SetupSOLZRC20()

SetupSOLZRC20 sets up the SOL ZRC20 in the runner from the values queried from the chain

func (*E2ERunner) SetupSolanaAccount

func (r *E2ERunner) SetupSolanaAccount()

SetupSolanaAccount imports the deployer's private key

func (*E2ERunner) Unlock

func (r *E2ERunner) Unlock()

Unlock unlocks the mutex

func (*E2ERunner) UpdateChainParamsV2Contracts

func (r *E2ERunner) UpdateChainParamsV2Contracts()

UpdateChainParamsV2Contracts update the erc20 custody contract and gateway address in the chain params this operation is used when transitioning to new smart contract architecture where a new ERC20 custody contract is deployed

func (*E2ERunner) UpdateTssAddressForConnector

func (r *E2ERunner) UpdateTssAddressForConnector()

func (*E2ERunner) UpdateTssAddressForErc20custody

func (r *E2ERunner) UpdateTssAddressForErc20custody()

func (*E2ERunner) V2ERC20Deposit

func (r *E2ERunner) V2ERC20Deposit(
	receiver ethcommon.Address,
	amount *big.Int,
	revertOptions gatewayevm.RevertOptions,
) *ethtypes.Transaction

V2ERC20Deposit calls Deposit of Gateway with erc20 token on EVM

func (*E2ERunner) V2ERC20DepositAndCall

func (r *E2ERunner) V2ERC20DepositAndCall(
	receiver ethcommon.Address,
	amount *big.Int,
	payload []byte,
	revertOptions gatewayevm.RevertOptions,
) *ethtypes.Transaction

V2ERC20DepositAndCall calls DepositAndCall of Gateway with erc20 token on EVM

func (*E2ERunner) V2ERC20Withdraw

func (r *E2ERunner) V2ERC20Withdraw(
	receiver ethcommon.Address,
	amount *big.Int,
	revertOptions gatewayzevm.RevertOptions,
) *ethtypes.Transaction

V2ERC20Withdraw calls Withdraw of Gateway with erc20 token on ZEVM

func (*E2ERunner) V2ERC20WithdrawAndCall

func (r *E2ERunner) V2ERC20WithdrawAndCall(
	receiver ethcommon.Address,
	amount *big.Int,
	payload []byte,
	revertOptions gatewayzevm.RevertOptions,
) *ethtypes.Transaction

V2ERC20WithdrawAndCall calls WithdrawAndCall of Gateway with erc20 token on ZEVM

func (*E2ERunner) V2ETHDeposit

func (r *E2ERunner) V2ETHDeposit(
	receiver ethcommon.Address,
	amount *big.Int,
	revertOptions gatewayevm.RevertOptions,
) *ethtypes.Transaction

V2ETHDeposit calls Deposit of Gateway with gas token on EVM

func (*E2ERunner) V2ETHDepositAndCall

func (r *E2ERunner) V2ETHDepositAndCall(
	receiver ethcommon.Address,
	amount *big.Int,
	payload []byte,
	revertOptions gatewayevm.RevertOptions,
) *ethtypes.Transaction

V2ETHDepositAndCall calls DepositAndCall of Gateway with gas token on EVM

func (*E2ERunner) V2ETHWithdraw

func (r *E2ERunner) V2ETHWithdraw(
	receiver ethcommon.Address,
	amount *big.Int,
	revertOptions gatewayzevm.RevertOptions,
) *ethtypes.Transaction

V2ETHWithdraw calls Withdraw of Gateway with gas token on ZEVM

func (*E2ERunner) V2ETHWithdrawAndCall

func (r *E2ERunner) V2ETHWithdrawAndCall(
	receiver ethcommon.Address,
	amount *big.Int,
	payload []byte,
	revertOptions gatewayzevm.RevertOptions,
) *ethtypes.Transaction

V2ETHWithdrawAndCall calls WithdrawAndCall of Gateway with gas token on ZEVM

func (*E2ERunner) V2EVMToZEMVCall

func (r *E2ERunner) V2EVMToZEMVCall(
	receiver ethcommon.Address,
	payload []byte,
	revertOptions gatewayevm.RevertOptions,
) *ethtypes.Transaction

V2EVMToZEMVCall calls Call of Gateway on EVM

func (*E2ERunner) V2ZEVMToEMVCall

func (r *E2ERunner) V2ZEVMToEMVCall(
	receiver ethcommon.Address,
	payload []byte,
	revertOptions gatewayzevm.RevertOptions,
) *ethtypes.Transaction

V2ZEVMToEMVCall calls Call of Gateway on ZEVM

func (*E2ERunner) WaitForBlocks

func (r *E2ERunner) WaitForBlocks(n int64)

func (*E2ERunner) WaitForMinedCCTX

func (r *E2ERunner) WaitForMinedCCTX(txHash ethcommon.Hash)

WaitForMinedCCTX waits for a cctx to be mined from a tx

func (*E2ERunner) WaitForMinedCCTXFromIndex

func (r *E2ERunner) WaitForMinedCCTXFromIndex(index string)

WaitForMinedCCTXFromIndex waits for a cctx to be mined from its index

func (*E2ERunner) WaitForTxReceiptOnEvm

func (r *E2ERunner) WaitForTxReceiptOnEvm(tx *ethtypes.Transaction)

WaitForTxReceiptOnEvm waits for a tx receipt on EVM

func (*E2ERunner) WaitForTxReceiptOnZEVM

func (r *E2ERunner) WaitForTxReceiptOnZEVM(tx *ethtypes.Transaction)

WaitForTxReceiptOnZEVM waits for a tx receipt on ZEVM

func (*E2ERunner) WithdrawERC20

func (r *E2ERunner) WithdrawERC20(amount *big.Int) *ethtypes.Transaction

WithdrawERC20 withdraws an ERC20 token from ZetaChain to the ZETA smart contract on EVM

func (*E2ERunner) WithdrawEther

func (r *E2ERunner) WithdrawEther(amount *big.Int) *ethtypes.Transaction

WithdrawEther withdraws Ether from ZetaChain to the ZETA smart contract on EVM

func (*E2ERunner) WithdrawSOLZRC20

func (r *E2ERunner) WithdrawSOLZRC20(
	to solana.PublicKey,
	amount *big.Int,
	approveAmount *big.Int,
) *crosschaintypes.CrossChainTx

WithdrawSOLZRC20 withdraws an amount of ZRC20 SOL tokens

func (*E2ERunner) WithdrawZeta

func (r *E2ERunner) WithdrawZeta(amount *big.Int, waitReceipt bool) *ethtypes.Transaction

WithdrawZeta withdraws ZETA from ZetaChain to the ZETA smart contract on EVM waitReceipt specifies whether to wait for the tx receipt and check if the tx was successful

type E2ERunnerOption

type E2ERunnerOption func(*E2ERunner)

func WithZetaTxServer

func WithZetaTxServer(txServer *txserver.ZetaTxServer) E2ERunnerOption

type E2ETest

type E2ETest struct {
	Name           string
	Description    string
	Args           []string
	ArgsDefinition []ArgDefinition
	E2ETest        E2ETestFunc
}

E2ETest represents a E2E test with a name, args, description and test func

func NewE2ETest

func NewE2ETest(name, description string, argsDefinition []ArgDefinition, e2eTestFunc E2ETestFunc) E2ETest

NewE2ETest creates a new instance of E2ETest with specified parameters.

func (E2ETest) ArgsDescription

func (e E2ETest) ArgsDescription() string

ArgsDescription returns a string representing the arguments description in a readable format.

func (E2ETest) DefaultArgs

func (e E2ETest) DefaultArgs() []string

DefaultArgs extracts and returns array of default arguments from the ArgsDefinition.

type E2ETestFunc

type E2ETestFunc func(*E2ERunner, []string)

E2ETestFunc is a function representing a E2E test It takes a E2ERunner as an argument

type E2ETestRunConfig

type E2ETestRunConfig struct {
	Name string
	Args []string
}

E2ETestRunConfig defines the basic configuration for initiating an E2E test, including its name and optional runtime arguments.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is a wrapper around log.Logger that adds verbosity

func NewLogger

func NewLogger(verbose bool, printColor color.Attribute, prefix string) *Logger

NewLogger creates a new Logger

func (*Logger) CCTX

func (l *Logger) CCTX(cctx crosschaintypes.CrossChainTx, name string)

CCTX prints a CCTX

func (*Logger) EVMReceipt

func (l *Logger) EVMReceipt(receipt ethtypes.Receipt, name string)

EVMReceipt prints a receipt

func (*Logger) EVMTransaction

func (l *Logger) EVMTransaction(tx ethtypes.Transaction, name string)

EVMTransaction prints a transaction

func (*Logger) Error

func (l *Logger) Error(message string, args ...interface{})

Error prints an error message to the logger

func (*Logger) GatewayDeposit

func (l *Logger) GatewayDeposit(
	contract depositParser,
	receipt ethtypes.Receipt,
	name string,
)

GatewayDeposit prints a GatewayDeposit event

func (*Logger) Info

func (l *Logger) Info(message string, args ...interface{})

Info prints a message to the logger if verbose is true

func (*Logger) InfoLoud

func (l *Logger) InfoLoud(message string, args ...interface{})

InfoLoud prints a message to the logger if verbose is true

func (*Logger) Prefix

func (l *Logger) Prefix() string

Prefix returns the prefix of the logger

func (*Logger) Print

func (l *Logger) Print(message string, args ...interface{})

Print prints a message to the logger

func (*Logger) PrintNoPrefix

func (l *Logger) PrintNoPrefix(message string, args ...interface{})

PrintNoPrefix prints a message to the logger without the prefix

func (*Logger) SetColor

func (l *Logger) SetColor(printColor color.Attribute)

SetColor sets the color of the logger

func (*Logger) ZRC20Withdrawal

func (l *Logger) ZRC20Withdrawal(
	contract interface {
		ParseWithdrawal(ethtypes.Log) (*zrc20.ZRC20Withdrawal, error)
	},
	receipt ethtypes.Receipt,
	name string,
)

ZRC20Withdrawal prints a ZRC20Withdrawal event

type NetworkReport

type NetworkReport struct {
	EmissionsPoolBalance sdkmath.Int
	Height               uint64
	CctxCount            int
}

NetworkReport is a struct that contains the report for the network used after running e2e tests This report has been initialized to check the emissions pool balance and if the pool is decreasing TODO: add more complete data and validation to the network https://github.com/zeta-chain/node/issues/1873

func (NetworkReport) Validate

func (nr NetworkReport) Validate() error

Validate validates the network report This method is used to validate the network after running e2e tests It checks the emissions pool balance and if the pool is decreasing

type Response

type Response struct {
	Amount Amount `json:"amount"`
}

type TestReport

type TestReport struct {
	Name     string
	Success  bool
	Time     time.Duration
	GasSpent AccountBalancesDiff
}

TestReport is a struct that contains the report for a specific e2e test It can be generated with the RunE2ETestsIntoReport method

type TestReports

type TestReports []TestReport

TestReports is a slice of TestReport

func (TestReports) String

func (tr TestReports) String(prefix string) (string, error)

String returns the string representation of the test report as a table it uses text/tabwriter to format the table

Jump to

Keyboard shortcuts

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