Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): allow to run E2E tests on any networks #1584

Merged
merged 61 commits into from
Feb 4, 2024
Merged

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Jan 15, 2024

Description

Makes the necessary changes to run E2E on any network.

Add a test for ETH withdraw

Tested with ETHGoerli right, experimentation with USDC, Bitcoin and BNB to be done after this week after upgrade.

Usage:

Build zetae2e with

make install-zetae2e

zetae2e needs a config file to run, (what key, networks, and test to run, what are the deployed contract addresses), format as follows (for Athens3):

zeta_chain_id: "athens_7001-1"
accounts:
  evm_address: "<your evm address>"
  evm_priv_key: "<your evm private key>"
rpcs:
  zevm: "<zevm (ZetaChain) url>, generally using port 8545"
  evm: "<evm url>, generally using port 8545"
  bitcoin:
    host: "<bitcoin rpc url>"
    user: "<bitcoin user>"
    pass: "<bitcoin pass>"
    http_post_mode: true
    disable_tls: true
    params: "<mainnet|testnet3|regnet>"
  zetacore_grpc: "<ZetaChain grpc url>, generally using port 9090"
  zetacore_rpc: "<ZetaChain grpc url>, generally using port 26657"
contracts:
  zevm:
    system_contract: "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B"
    eth_zrc20: "0x13A0c5930C028511Dc02665E7285134B6d11A5f4"
    usdt_zrc20: "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a"
    btc_zrc20: "0x65a45c57636f9BcCeD4fe193A602008578BcA90b"
    uniswap_factory: "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c"
    uniswap_router: "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe"
  evm:
    zeta_eth: "0x0000c304d2934c00db1d51995b9f6996affd17c0"
    connector_eth: "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea"
    custody: "0x000047f11c6e42293f433c82473532e869ce4ec5"
    usdt: "0x07865c6e87b9f70255377e024ace6630c1eaa37f"
test_list:
  - "eth_deposit"
  - "eth_withdraw" --> the list of tests to run using the test names defined in `smoketests.go`

The commands require the config file to run.

  • Print the Bitcoin address used from the used Ethereum key
$zetae2e bitcoin-address config.yml
           | * BTC address: tb1qz7n05rg9swm97h4lyyx2uuphzm0cxd6sj529k4
  • Show the balances on the different networks for the account used
$zetae2e balances config.yml
           |  ---💰 Account info 0xb741531a1A8984d5188d1058f47EB7cBd57F4655 ---
           | ZetaChain:
           | * ZETA balance:  4049776838665491356
           | * ETH balance:   3996999999998944000
           | * ERC20 balance: 0
           | Ethereum:
           | * ZETA balance:  0
           | * ETH balance:   265999999999999355000
           | * ERC20 balance: 10000000
  • Run the E2E tests
$zetae2e run config.yml [--verbose]

The E2E tests execution doesn't stop if one of the test fails, instead all the tests are run, at the end of the execution a report is shown in the console to show the tokens that have been consumed by the tests, the time completion, if successful, etc..
Example with a test on Athens3:

e2e        |  ---💰 Total gas spent ---
e2e        | * ZETA spent:  729771
e2e        | * ETH spent:   1000000000588000
e2e        |  ---📈 E2E Test Report ---
Name            Success    Time               Spent
eth_deposit     ✅          2m17.758949375s    ETH:273000
eth_withdraw    ✅          6m2.659396333s     ETH:1000000000315000,ZETA:729771

Closes: #1482 #1448

@lumtis lumtis linked an issue Jan 15, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Jan 16, 2024

!!!WARNING!!!
nosec detected in the following files: contrib/localnet/orchestrator/smoketest/runner/logger.go, contrib/localnet/orchestrator/smoketest/smoketests/smoketests.go, contrib/localnet/orchestrator/smoketest/smoketests/test_bitcoin_withdraw.go

Be very careful about using #nosec in code. It can be a quick way to suppress security warnings and move forward with development, it should be employed with caution. Suppressing warnings with #nosec can hide potentially serious vulnerabilities. Only use #nosec when you're absolutely certain that the security issue is either a false positive or has been mitigated in another way.

Only suppress a single rule (or a specific set of rules) within a section of code, while continuing to scan for other problems. To do this, you can list the rule(s) to be suppressed within the #nosec annotation, e.g: /* #nosec G401 */ or //#nosec G201 G202 G203
Broad #nosec annotations should be avoided, as they can hide other vulnerabilities. The CI will block you from merging this PR until you remove #nosec annotations that do not target specific rules.

Pay extra attention to the way #nosec is being used in the files listed above.

@github-actions github-actions bot added the nosec label Jan 16, 2024
@lumtis lumtis marked this pull request as ready for review January 16, 2024 02:15
Copy link
Contributor

@kingpinXD kingpinXD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great !

Copy link
Contributor

@kevinssgh kevinssgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@lumtis lumtis merged commit 7d86651 into develop Feb 4, 2024
15 checks passed
@lumtis lumtis deleted the test/e2e-networks branch February 4, 2024 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to run smoke test orchestrator on any network Add a withdraw_eth smoke test
4 participants