Documentation ¶
Index ¶
- Constants
- Variables
- type AccountBalances
- type AccountBalancesDiff
- type Amount
- type ArgDefinition
- type E2ERunner
- func (r *E2ERunner) AddTSSToNode()
- func (r *E2ERunner) AnvilMineBlocks(url string, blockTime int) (func(), error)
- func (r *E2ERunner) CheckBtcTSSBalance() error
- func (r *E2ERunner) CheckZRC20ReserveAndSupply() error
- func (r *E2ERunner) CopyAddressesFrom(other *E2ERunner) (err error)
- func (r *E2ERunner) DepositAndApproveWZeta(amount *big.Int)
- func (r *E2ERunner) DepositBTC(testHeader bool)
- func (r *E2ERunner) DepositBTCWithAmount(amount float64) *chainhash.Hash
- func (r *E2ERunner) DepositERC20() ethcommon.Hash
- func (r *E2ERunner) DepositERC20WithAmountAndMessage(to ethcommon.Address, amount *big.Int, msg []byte) ethcommon.Hash
- func (r *E2ERunner) DepositEther(testHeader bool) ethcommon.Hash
- func (r *E2ERunner) DepositEtherWithAmount(testHeader bool, amount *big.Int) ethcommon.Hash
- func (r *E2ERunner) DepositZeta() ethcommon.Hash
- func (r *E2ERunner) DepositZetaWithAmount(to ethcommon.Address, amount *big.Int) ethcommon.Hash
- func (r *E2ERunner) EVMAddress() ethcommon.Address
- func (r *E2ERunner) EnableHeaderVerification(chainIDList []int64) error
- func (r *E2ERunner) Errorf(format string, args ...any)
- func (r *E2ERunner) FailNow()
- func (r *E2ERunner) FundEmissionsPool() error
- func (r *E2ERunner) GenerateNetworkReport() (NetworkReport, error)
- func (r *E2ERunner) GenerateToAddressIfLocalBitcoin(numBlocks int64, address btcutil.Address) ([]*chainhash.Hash, error)
- func (r *E2ERunner) GetAccountBalances(skipBTC bool) (AccountBalances, error)
- func (r *E2ERunner) GetBitcoinBalance() (string, error)
- func (r *E2ERunner) GetBitcoinBalanceByAddress(address btcutil.Address) (btcutil.Amount, error)
- func (r *E2ERunner) GetBitcoinChainID() int64
- func (r *E2ERunner) GetBtcAddress() (string, string, error)
- func (r *E2ERunner) GetE2ETestsToRunByConfig(availableTests []E2ETest, testConfigs []E2ETestRunConfig) ([]E2ETest, error)
- func (r *E2ERunner) GetE2ETestsToRunByName(availableTests []E2ETest, testNames ...string) ([]E2ETest, error)
- func (r *E2ERunner) GetTop20UTXOsForTssAddress() ([]btcjson.ListUnspentResult, error)
- func (r *E2ERunner) IsLocalBitcoin() bool
- func (r *E2ERunner) ListDeployerUTXOs() ([]btcjson.ListUnspentResult, error)
- func (r *E2ERunner) Lock()
- func (r *E2ERunner) MineBlocksIfLocalBitcoin() func()
- func (r *E2ERunner) MintERC20OnEvm(amountERC20 int64)
- func (r *E2ERunner) PrintAccountBalances(balances AccountBalances)
- func (r *E2ERunner) PrintContractAddresses()
- func (r *E2ERunner) PrintNetworkReport(nr NetworkReport)
- func (r *E2ERunner) PrintTestReports(tr TestReports)
- func (r *E2ERunner) PrintTotalDiff(accoutBalancesDiff AccountBalancesDiff)
- func (r *E2ERunner) ProveBTCTransaction(txHash *chainhash.Hash)
- func (r *E2ERunner) ProveEthTransaction(receipt *ethtypes.Receipt)
- func (r *E2ERunner) RunE2ETest(e2eTest E2ETest, checkAccounting bool) error
- func (r *E2ERunner) RunE2ETests(e2eTests []E2ETest) (err error)
- func (r *E2ERunner) RunE2ETestsIntoReport(e2eTests []E2ETest) (TestReports, error)
- func (r *E2ERunner) SendERC20OnEvm(address ethcommon.Address, amountERC20 int64) *ethtypes.Transaction
- func (r *E2ERunner) SendEther(_ ethcommon.Address, value *big.Int, data []byte) (*ethtypes.Transaction, error)
- func (r *E2ERunner) SendToTSSFromDeployerToDeposit(amount float64, inputUTXOs []btcjson.ListUnspentResult) (*chainhash.Hash, error)
- func (r *E2ERunner) SendToTSSFromDeployerWithMemo(amount float64, inputUTXOs []btcjson.ListUnspentResult, memo []byte) (*chainhash.Hash, error)
- func (r *E2ERunner) SendZetaOnEvm(address ethcommon.Address, zetaAmount int64) *ethtypes.Transaction
- func (r *E2ERunner) SetBtcAddress(name string, rescan bool)
- func (r *E2ERunner) SetEVMContractsFromConfig()
- func (r *E2ERunner) SetTSSAddresses() error
- func (r *E2ERunner) SetZEVMContracts()
- func (r *E2ERunner) SetupBTCZRC20()
- func (r *E2ERunner) SetupBitcoinAccount(initNetwork bool)
- func (r *E2ERunner) SetupETHZRC20()
- func (r *E2ERunner) SetupEVM(contractsDeployed bool, whitelistERC20 bool)
- func (r *E2ERunner) Unlock()
- func (r *E2ERunner) WaitForMinedCCTX(txHash ethcommon.Hash)
- func (r *E2ERunner) WaitForMinedCCTXFromIndex(index string)
- func (r *E2ERunner) WaitForTxReceiptOnEvm(tx *ethtypes.Transaction)
- func (r *E2ERunner) WaitForTxReceiptOnZEVM(tx *ethtypes.Transaction)
- func (r *E2ERunner) WithdrawERC20(amount *big.Int) *ethtypes.Transaction
- func (r *E2ERunner) WithdrawEther(amount *big.Int) *ethtypes.Transaction
- func (r *E2ERunner) WithdrawZeta(amount *big.Int, waitReceipt bool) *ethtypes.Transaction
- type E2ERunnerOption
- type E2ETest
- type E2ETestFunc
- type E2ETestRunConfig
- type Logger
- func (l *Logger) CCTX(cctx crosschaintypes.CrossChainTx, name string)
- func (l *Logger) EVMReceipt(receipt ethtypes.Receipt, name string)
- func (l *Logger) EVMTransaction(tx ethtypes.Transaction, name string)
- func (l *Logger) Error(message string, args ...interface{})
- func (l *Logger) Info(message string, args ...interface{})
- func (l *Logger) InfoLoud(message string, args ...interface{})
- func (l *Logger) Prefix() string
- func (l *Logger) Print(message string, args ...interface{})
- func (l *Logger) PrintNoPrefix(message string, args ...interface{})
- func (l *Logger) SetColor(printColor color.Attribute)
- func (l *Logger) ZRC20Withdrawal(contract interface{ ... }, receipt ethtypes.Receipt, name string)
- type NetworkReport
- type Response
- type TestReport
- type TestReports
Constants ¶
const (
ContractsConfigFile = "contracts.toml"
)
Variables ¶
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 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 ¶
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 ArgDefinition ¶
ArgDefinition defines a structure for holding an argument's description along with it's default value.
type E2ERunner ¶
type E2ERunner struct { // accounts Account config.Account TSSAddress ethcommon.Address BTCTSSAddress btcutil.Address BTCDeployerAddress *btcutil.AddressWitnessPubKeyHash // rpc clients ZEVMClient *ethclient.Client EVMClient *ethclient.Client BtcRPCClient *rpcclient.Client // grpc clients CctxClient crosschaintypes.QueryClient FungibleClient fungibletypes.QueryClient AuthClient authtypes.QueryClient BankClient banktypes.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 // 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 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 // 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, evmClient *ethclient.Client, zevmClient *ethclient.Client, cctxClient crosschaintypes.QueryClient, fungibleClient fungibletypes.QueryClient, authClient authtypes.QueryClient, bankClient banktypes.QueryClient, observerClient observertypes.QueryClient, lightclientClient lightclienttypes.QueryClient, evmAuth *bind.TransactOpts, zevmAuth *bind.TransactOpts, btcRPCClient *rpcclient.Client, logger *Logger, opts ...E2ERunnerOption, ) *E2ERunner
func (*E2ERunner) AddTSSToNode ¶
func (r *E2ERunner) AddTSSToNode()
func (*E2ERunner) AnvilMineBlocks ¶
AnvilMineBlocks mines blocks on Anvil localnet the block time is provided in seconds the method returns a function to stop the mining
func (*E2ERunner) CheckBtcTSSBalance ¶
func (*E2ERunner) CheckZRC20ReserveAndSupply ¶
func (*E2ERunner) CopyAddressesFrom ¶
CopyAddressesFrom copies addresses from another E2ETestRunner that initialized the contracts
func (*E2ERunner) DepositAndApproveWZeta ¶
DepositAndApproveWZeta deposits and approves WZETA on ZetaChain from the ZETA smart contract on ZEVM
func (*E2ERunner) DepositBTC ¶
DepositBTC deposits BTC on ZetaChain
func (*E2ERunner) DepositBTCWithAmount ¶
DepositBTCWithAmount deposits BTC on ZetaChain with a specific amount
func (*E2ERunner) DepositERC20 ¶
func (*E2ERunner) DepositERC20WithAmountAndMessage ¶
func (*E2ERunner) DepositEther ¶
DepositEther sends Ethers into ZEVM
func (*E2ERunner) DepositEtherWithAmount ¶
DepositEtherWithAmount sends Ethers into ZEVM
func (*E2ERunner) DepositZeta ¶
DepositZeta deposits ZETA on ZetaChain from the ZETA smart contract on EVM
func (*E2ERunner) DepositZetaWithAmount ¶
DepositZetaWithAmount deposits ZETA on ZetaChain from the ZETA smart contract on EVM with the specified amount
func (*E2ERunner) EVMAddress ¶
EVMAddress is shorthand to get the EVM address of the account
func (*E2ERunner) EnableHeaderVerification ¶
EnableHeaderVerification enables the header verification for the given chain IDs
func (*E2ERunner) FailNow ¶
func (r *E2ERunner) FailNow()
FailNow implemented to mimic the behavior of testing.T.FailNow
func (*E2ERunner) FundEmissionsPool ¶
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 ¶
GetBitcoinBalance returns the spendable BTC balance of the BTC address
func (*E2ERunner) GetBitcoinBalanceByAddress ¶
GetBitcoinBalanceByAddress get btc balance by address.
func (*E2ERunner) GetBitcoinChainID ¶
GetBitcoinChainID gets the bitcoin chain ID from the network params
func (*E2ERunner) GetBtcAddress ¶
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 ¶
IsLocalBitcoin returns true if the runner is running on a local bitcoin network
func (*E2ERunner) ListDeployerUTXOs ¶
func (r *E2ERunner) ListDeployerUTXOs() ([]btcjson.ListUnspentResult, error)
ListDeployerUTXOs list the deployer's UTXOs
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 ¶
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) ProveBTCTransaction ¶
ProveBTCTransaction proves that a BTC transaction is in a block header and that the block header is in ZetaChain
func (*E2ERunner) ProveEthTransaction ¶
ProveEthTransaction proves an ETH transaction on ZetaChain
func (*E2ERunner) RunE2ETest ¶
RunE2ETest runs a e2e test
func (*E2ERunner) RunE2ETests ¶
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) 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 (*E2ERunner) SendToTSSFromDeployerWithMemo ¶
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 ¶
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) SetTSSAddresses ¶
SetTSSAddresses set TSS addresses from information queried from ZetaChain
func (*E2ERunner) SetZEVMContracts ¶
func (r *E2ERunner) SetZEVMContracts()
SetZEVMContracts set contracts 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 (*E2ERunner) SetupETHZRC20 ¶
func (r *E2ERunner) SetupETHZRC20()
SetupETHZRC20 sets up the ETH ZRC20 in the runner from the values queried from the chain
func (*E2ERunner) WaitForMinedCCTX ¶
WaitForMinedCCTX waits for a cctx to be mined from a tx
func (*E2ERunner) WaitForMinedCCTXFromIndex ¶
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) WithdrawZeta ¶
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 ¶
ArgsDescription returns a string representing the arguments description in a readable format.
func (E2ETest) DefaultArgs ¶
DefaultArgs extracts and returns array of default arguments from the ArgsDefinition.
type E2ETestFunc ¶
E2ETestFunc is a function representing a E2E test It takes a E2ERunner as an argument
type E2ETestRunConfig ¶
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 (*Logger) CCTX ¶
func (l *Logger) CCTX(cctx crosschaintypes.CrossChainTx, name string)
CCTX prints a CCTX
func (*Logger) EVMReceipt ¶
EVMReceipt prints a receipt
func (*Logger) EVMTransaction ¶
func (l *Logger) EVMTransaction(tx ethtypes.Transaction, name string)
EVMTransaction prints a transaction
func (*Logger) PrintNoPrefix ¶
PrintNoPrefix prints a message to the logger without the prefix
type NetworkReport ¶
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 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