runner

package
v0.0.0-...-cc3bc86 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 94 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
	TON     *tonrunner.Client

	// 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
	TONDeployer           *tonrunner.Deployer
	TONGateway            *toncontracts.Gateway
	FeeCollectorAddress   types.AccAddress

	// 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
	DistributionClient distributiontypes.QueryClient
	EmissionsClient    emissionstypes.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
	SPLAddr        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
	SPLZRC20Addr         ethcommon.Address
	SPLZRC20             *zrc20.ZRC20
	ETHZRC20Addr         ethcommon.Address
	ETHZRC20             *zrc20.ZRC20
	BTCZRC20Addr         ethcommon.Address
	BTCZRC20             *zrc20.ZRC20
	SOLZRC20Addr         ethcommon.Address
	SOLZRC20             *zrc20.ZRC20
	TONZRC20Addr         ethcommon.Address
	TONZRC20             *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) AddInboundTracker

func (r *E2ERunner) AddInboundTracker(coinType coin.CoinType, txHash string)

AddInboundTracker adds an inbound tracker from the tx hash

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) CheckZRC20BalanceAndSupply

func (r *E2ERunner) CheckZRC20BalanceAndSupply()

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) CreateDepositSPLInstruction

func (r *E2ERunner) CreateDepositSPLInstruction(
	amount uint64,
	signer solana.PublicKey,
	whitelistEntry solana.PublicKey,
	mint solana.PublicKey,
	from solana.PublicKey,
	to solana.PublicKey,
	receiver ethcommon.Address,
	data []byte,
) solana.Instruction

CreateDepositSPLInstruction creates a 'deposit_spl' instruction

func (*E2ERunner) CreateSignedTransaction

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

CreateSignedTransaction creates a signed transaction from instructions

func (*E2ERunner) CreateWhitelistSPLMintInstruction

func (r *E2ERunner) CreateWhitelistSPLMintInstruction(
	signer, whitelistEntry, whitelistCandidate solana.PublicKey,
) solana.Instruction

CreateWhitelistSPLMintInstruction creates a 'whitelist_spl_mint' instruction

func (*E2ERunner) DeploySPL

func (r *E2ERunner) DeploySPL(privateKey *solana.PrivateKey, whitelist bool) *solana.Wallet

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(receiver common.Address)

DepositBTC deposits BTC from the Bitcoin node wallet into ZetaChain. Note: This function only works for node wallet based deployer account.

func (*E2ERunner) DepositBTCWithAmount

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

DepositBTCWithAmount deposits BTC into ZetaChain with a specific amount and memo

func (*E2ERunner) DepositBTCWithLegacyMemo

func (r *E2ERunner) DepositBTCWithLegacyMemo(
	amount float64,
	inputUTXOs []btcjson.ListUnspentResult,
	receiver common.Address,
) (*chainhash.Hash, error)

DepositBTCWithLegacyMemo deposits BTC from the deployer address to the TSS using legacy memo

The legacy memo layout: [20-byte receiver] + [payload]

func (*E2ERunner) DepositBTCWithStandardMemo

func (r *E2ERunner) DepositBTCWithStandardMemo(
	amount float64,
	inputUTXOs []btcjson.ListUnspentResult,
	memoStd *memo.InboundMemo,
) (*chainhash.Hash, error)

DepositBTCWithStandardMemo deposits BTC from the deployer address to the TSS using standard `InboundMemo` struct

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) EnsureZeroBalanceOnRestrictedAddressZEVM

func (r *E2ERunner) EnsureZeroBalanceOnRestrictedAddressZEVM()

EnsureZeroBalanceAddressZEVM ensures that the balance of the restricted 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() (*btcutil.AddressWitnessPubKeyHash, *btcutil.WIF)

GetBtcAddress returns the BTC address of the deployer and private key in WIF format

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) GetSolanaPrivKey

func (r *E2ERunner) GetSolanaPrivKey() solana.PrivateKey

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) InscribeToTSSFromDeployerWithMemo

func (r *E2ERunner) InscribeToTSSFromDeployerWithMemo(
	amount float64,
	memo []byte,
	feeRate int64,
) (*chainhash.Hash, int64)

InscribeToTSSFromDeployerWithMemo creates an inscription that is sent to the tss address with the corresponding memo

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) QueryOutboundReceiverAndAmount

func (r *E2ERunner) QueryOutboundReceiverAndAmount(txid string) (string, int64)

QueryOutboundReceiverAndAmount queries the outbound receiver and amount (in satoshis) from the given txid

func (*E2ERunner) ResolveSolanaATA

func (r *E2ERunner) ResolveSolanaATA(
	payer solana.PrivateKey,
	owner solana.PublicKey,
	mintAccount solana.PublicKey,
) solana.PublicKey

ResolveSolanaATA finds or creates SOL associated token account

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) SPLDepositAndCall

func (r *E2ERunner) SPLDepositAndCall(
	privateKey *solana.PrivateKey,
	amount uint64,
	mintAccount solana.PublicKey,
	receiver ethcommon.Address,
	data []byte,
) solana.Signature

SPLDepositAndCall deposits an amount of SPL tokens 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) SendToTSSFromDeployerWithMemo

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

func (*E2ERunner) SendWithdrawTONZRC20

func (r *E2ERunner) SendWithdrawTONZRC20(
	to ton.AccountID,
	amount *big.Int,
	approveAmount *big.Int,
) *ethtypes.Transaction

SendWithdrawTONZRC20 sends withdraw tx of TON ZRC20 tokens

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) SetEVMContractsFromConfig

func (r *E2ERunner) SetEVMContractsFromConfig()

SetEVMContractsFromConfig set EVM contracts for e2e test from the config

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(zrc20Deployment txserver.ZRC20Deployment)

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) SetupBitcoinAccounts

func (r *E2ERunner) SetupBitcoinAccounts(createWallet bool)

SetupBitcoinAccounts sets up the TSS account and deployer account

func (*E2ERunner) SetupBtcAddress

func (r *E2ERunner) SetupBtcAddress(createWallet bool)

SetupBtcAddress setups the deployer Bitcoin address

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) SetupSolana

func (r *E2ERunner) SetupSolana(gatewayID, deployerPrivateKey string)

SetupSolana sets Solana contracts and params

func (*E2ERunner) SetupSolanaAccount

func (r *E2ERunner) SetupSolanaAccount()

SetupSolanaAccount imports the deployer's private key

func (*E2ERunner) SetupTON

func (r *E2ERunner) SetupTON() error

SetupTON setups TON deployer and deploys Gateway contract

func (*E2ERunner) SetupTONZRC20

func (r *E2ERunner) SetupTONZRC20()

SetupTONZRC20 sets up the TON ZRC20 in the runner from the values queried from the chain

func (*E2ERunner) SolanaRentPayerPDA

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

SolanaRentPayerPDA computes the rent payer PDA (Program Derived Address) address for the gateway program

func (*E2ERunner) TONDeposit

func (r *E2ERunner) TONDeposit(
	sender *wallet.Wallet,
	amount math.Uint,
	zevmRecipient eth.Address,
) (*cctypes.CrossChainTx, error)

TONDeposit deposit TON to Gateway contract

func (*E2ERunner) TONDepositAndCall

func (r *E2ERunner) TONDepositAndCall(
	sender *wallet.Wallet,
	amount math.Uint,
	zevmRecipient eth.Address,
	callData []byte,
	opts ...TONOpt,
) (*cctypes.CrossChainTx, error)

TONDepositAndCall deposit TON to Gateway contract with call data.

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) UpgradeERC20Custody

func (r *E2ERunner) UpgradeERC20Custody()

UpgradeERC20CustodyZEVM upgrades the ERC20Custody contract

func (*E2ERunner) UpgradeGatewayEVM

func (r *E2ERunner) UpgradeGatewayEVM()

UpgradeGatewayEVM upgrades the GatewayEVM contract

func (*E2ERunner) UpgradeGatewayZEVM

func (r *E2ERunner) UpgradeGatewayZEVM()

UpgradeGatewayZEVM upgrades the GatewayZEVM contract

func (*E2ERunner) UpgradeGatewaysAndERC20Custody

func (r *E2ERunner) UpgradeGatewaysAndERC20Custody()

UpgradeGatewaysAndERC20Custody upgrades gateways and ERC20Custody contracts It deploys new contract implementation with the current imported artifacts and upgrades the contract

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) V2ERC20WithdrawAndArbitraryCall

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

V2ERC20WithdrawAndArbitraryCall calls WithdrawAndCall of Gateway with erc20 token on ZEVM using arbitrary call

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 using authenticated call

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) V2ETHWithdrawAndArbitraryCall

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

V2ETHWithdrawAndArbitraryCall calls WithdrawAndCall of Gateway with gas token on ZEVM using arbitrary call

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 using authenticated call

func (*E2ERunner) V2ETHWithdrawAndCallThroughContract

func (r *E2ERunner) V2ETHWithdrawAndCallThroughContract(
	gatewayZEVMCaller *gatewayzevmcaller.GatewayZEVMCaller,
	receiver ethcommon.Address,
	amount *big.Int,
	payload []byte,
	revertOptions gatewayzevmcaller.RevertOptions,
) *ethtypes.Transaction

V2ETHWithdrawAndCallThroughContract calls WithdrawAndCall of Gateway with gas token on ZEVM using authenticated call through contract

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) V2ZEVMToEMVArbitraryCall

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

V2ZEVMToEMVArbitraryCall calls Call of Gateway on ZEVM using arbitrary call

func (*E2ERunner) V2ZEVMToEMVCall

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

V2ZEVMToEMVCall calls authenticated Call of Gateway on ZEVM using authenticated call

func (*E2ERunner) V2ZEVMToEMVCallThroughContract

func (r *E2ERunner) V2ZEVMToEMVCallThroughContract(
	gatewayZEVMCaller *gatewayzevmcaller.GatewayZEVMCaller,
	receiver ethcommon.Address,
	payload []byte,
	revertOptions gatewayzevmcaller.RevertOptions,
) *ethtypes.Transaction

V2ZEVMToEMVCallThroughContract calls authenticated Call of Gateway on ZEVM through contract using authenticated call

func (*E2ERunner) WaitForBlocks

func (r *E2ERunner) WaitForBlocks(n int64)

WaitForBlocks waits for a specific number of blocks to be generated The parameter n is the number of blocks to wait for

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) *types.CrossChainTx

WaitForMinedCCTXFromIndex waits for a cctx to be mined from its index

func (*E2ERunner) WaitForSpecificCCTX

func (r *E2ERunner) WaitForSpecificCCTX(
	filter func(*types.CrossChainTx) bool,
	status types.CctxStatus,
	timeout time.Duration,
) *types.CrossChainTx

WaitForSpecificCCTX scans for cctx by filters and ensures it's mined

func (*E2ERunner) WaitForTSSGeneration

func (r *E2ERunner) WaitForTSSGeneration(tssNumber int64)

WaitForTSSGeneration waits for a specific number of TSS to be generated The parameter n is the number of TSS to wait for

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) WithdrawEmissions

func (r *E2ERunner) WithdrawEmissions() error

WithdrawEmissions withdraws emissions from the emission pool on ZetaChain for all observers This functions uses the UserEmissionsWithdrawName to create the withdraw tx. UserEmissionsWithdraw can sign the authz transactions because the necessary permissions are granted in the genesis file

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,
) *ethtypes.Transaction

WithdrawSOLZRC20 withdraws an amount of ZRC20 SOL tokens

func (*E2ERunner) WithdrawSPLZRC20

func (r *E2ERunner) WithdrawSPLZRC20(
	to solana.PublicKey,
	amount *big.Int,
	approveAmount *big.Int,
) *ethtypes.Transaction

WithdrawSPLZRC20 withdraws an amount of ZRC20 SPL tokens

func (*E2ERunner) WithdrawTONZRC20

func (r *E2ERunner) WithdrawTONZRC20(to ton.AccountID, amount *big.Int, approveAmount *big.Int) *cctypes.CrossChainTx

WithdrawTONZRC20 withdraws an amount of ZRC20 TON tokens and waits for the cctx to be mined

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 LeafScriptBuilder

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

LeafScriptBuilder represents a builder for Taproot leaf scripts

func NewLeafScriptBuilder

func NewLeafScriptBuilder(pubKey *btcec.PublicKey) *LeafScriptBuilder

NewLeafScriptBuilder initializes a new LeafScriptBuilder with a public key and `OP_CHECKSIG`

func (*LeafScriptBuilder) PushData

func (b *LeafScriptBuilder) PushData(data []byte)

PushData adds a large data to the Taproot leaf script following OP_FALSE and OP_IF structure

func (*LeafScriptBuilder) Script

func (b *LeafScriptBuilder) Script() ([]byte, error)

Script returns the current script

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 ...any)

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 TONOpt

type TONOpt func(t *tonOpts)

func TONExpectStatus

func TONExpectStatus(status cctypes.CctxStatus) TONOpt

type TapscriptSpender

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

TapscriptSpender is a utility struct that helps create Taproot address and reveal transaction

func NewTapscriptSpender

func NewTapscriptSpender(net *chaincfg.Params) *TapscriptSpender

NewTapscriptSpender creates a new NewTapscriptSpender instance

func (*TapscriptSpender) BuildRevealTxn

func (s *TapscriptSpender) BuildRevealTxn(
	to btcutil.Address,
	commitTxn wire.OutPoint,
	commitAmount int64,
	feeRate int64,
) (*wire.MsgTx, error)

BuildRevealTxn returns a signed reveal transaction that spends the commit transaction

func (*TapscriptSpender) GenerateCommitAddress

func (s *TapscriptSpender) GenerateCommitAddress(memo []byte) (*btcutil.AddressTaproot, error)

GenerateCommitAddress generates a Taproot commit address for the given receiver and payload

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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