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

feat(e2e): add support for dynamically resolving erc20 addresses #2783

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Aug 28, 2024

Allow setting erc20 info via cli parameters. When provided, we will resolve the addresses via RPC call. This is a bit tricky/fragile because the naming of our foreign coins are not consistent across different networks.

Also tolerate nil contract address in balance checks and remove duplicate balance check (it's already done by the test report).

Related to https://github.com/zeta-chain/infrastructure/issues/1498

➜  zetae2e git:(zetae2e-erc20-dynamic) ✗ ./zetae2e run -c config/local.yml --erc20-chain-name goerli_localnet --erc20-symbol USDT erc20_deposit:200000
e2e        | starting tests
e2e        | ⚙️ setting up TSS address
e2e        | [ERROR]get SOL balance: zrc20 contract is nil
e2e        | ⏳running - deposit ERC20 into ZEVM
e2e        | ✅ completed in 20.095935555s - deposit ERC20 into ZEVM
e2e        | [ERROR]get SOL balance: zrc20 contract is nil
e2e        | tests finished successfully in 25.123415485s
e2e        |  ---📈 E2E Test Report ---
Name             Success    Time             Spent
erc20_deposit    ✅          25.118187973s    ETH:1055496

➜  zetae2e git:(zetae2e-erc20-dynamic) ✗ ./zetae2e run -c config/local.yml --erc20-chain-name goerli_localnet --erc20-symbol asdf erc20_deposit:200000
Error: erc20 asdf not found on goerli_localnet
Usage:
  zetae2e run [testname1]:[arg1],[arg2] [testname2]:[arg1],[arg2]... [flags]

Flags:
  -c, --config string             path to the configuration file
      --erc20-chain-name string   chain_name from /zeta-chain/observer/chain_params structure
      --erc20-symbol string       erc20_name from /zeta-chain/fungible/foreign_coins structure
  -h, --help                      help for run
      --verbose                   set to true to enable verbose logging

erc20 asdf not found on goerli_localnet

Summary by CodeRabbit

  • New Features

    • Added new command-line flags for specifying ERC20 chain name and symbol during E2E tests.
    • Introduced dynamic configuration capabilities for E2E tests based on user input.
  • Bug Fixes

    • Enhanced error handling for retrieving balances from ZRC20 contracts, improving robustness.
  • Refactor

    • Simplified logging in the test report functionality by removing unnecessary arguments.
  • Chores

    • Improved naming conventions for exported types and functions to enhance code clarity.

Copy link
Contributor

coderabbitai bot commented Aug 28, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Walkthrough

The changes involve modifications to the E2EClients and ZetaChainClients structures, the addition of new command-line flags for dynamic configuration in E2E tests, enhancements to error handling for balance retrieval in ZRC20 contracts, and a refinement in the logging functionality of the PrintTestReports method. These updates aim to improve code clarity, configurability, and robustness across the testing framework.

Changes

File Path Change Summary
cmd/zetae2e/config/clients.go Renamed zetaChainClients to ZetaChainClients and getZetaClients to GetZetaClients, updated return types, and modified variable declarations and error handling in getClientsFromConfig.
cmd/zetae2e/run.go Added flags flagERC20ChainName and flagERC20Symbol, modified runE2ETest to utilize these flags, and streamlined the process by removing previous balance checks.
e2e/runner/balances.go Introduced errNilZRC20 for nil contract handling, added getZRC20BalanceSafe for centralized balance retrieval logic, and modified error handling for SOL balance retrieval.
e2e/runner/report.go Simplified the PrintTestReports method by removing an unnecessary empty string argument from the logging call.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gartnera gartnera force-pushed the zetae2e-erc20-dynamic branch from d42552a to 74c49aa Compare August 28, 2024 17:46
@gartnera gartnera changed the title e2e: add support for dynamically resolving erc20 addresses feat(e2e): add support for dynamically resolving erc20 addresses Aug 28, 2024
cmd/zetae2e/run.go Outdated Show resolved Hide resolved
cmd/zetae2e/run.go Outdated Show resolved Hide resolved
e2e/config/config.go Outdated Show resolved Hide resolved
@gartnera gartnera force-pushed the zetae2e-erc20-dynamic branch from 13a7b7d to e214c06 Compare August 28, 2024 20:34
@gartnera gartnera force-pushed the zetae2e-erc20-dynamic branch from e214c06 to d4a4858 Compare August 28, 2024 20:37
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 26c4fb1 and 2a70133.

Files selected for processing (4)
  • cmd/zetae2e/config/clients.go (4 hunks)
  • cmd/zetae2e/run.go (6 hunks)
  • e2e/runner/balances.go (3 hunks)
  • e2e/runner/report.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • e2e/runner/report.go
Additional context used
Path-based instructions (3)
cmd/zetae2e/config/clients.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

cmd/zetae2e/run.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

e2e/runner/balances.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

Additional comments not posted (8)
cmd/zetae2e/config/clients.go (3)

76-76: LGTM!

The function correctly uses the new exported function GetZetaClients.

The code changes are approved.


155-157: LGTM!

The function adheres to Go's naming conventions for exported functions and types. The error handling and client initialization logic are correctly implemented.

The code changes are approved.

Also applies to: 162-173


46-47: LGTM!

The type adheres to Go's naming conventions for exported types. The fields remain consistent with the previous implementation.

The code changes are approved.

cmd/zetae2e/run.go (3)

25-26: LGTM!

The addition of the new flags enhances the configurability of the E2E tests. The flags are correctly defined and integrated into the command.

The code changes are approved.

Also applies to: 48-50


77-85: LGTM!

The function correctly retrieves the new flag values and updates the configuration if both flags are provided. The error handling is consistent with the rest of the function.

The code changes are approved.


167-207: LGTM!

The function correctly handles the dynamic resolution of ERC20 addresses. The error handling and logic for querying supported chains and foreign coins are well-implemented.

The code changes are approved.

e2e/runner/balances.go (2)

37-42: LGTM!

The function correctly checks for a nil contract before attempting to call BalanceOf. This centralizes error handling for ZRC20 balance retrieval.

The code changes are approved.


55-69: LGTM!

The function correctly uses getZRC20BalanceSafe for ZRC20 balance retrieval, improving error handling and robustness.

The code changes are approved.

cmd/zetae2e/run.go Show resolved Hide resolved
cmd/zetae2e/run.go Show resolved Hide resolved
cmd/zetae2e/run.go Outdated Show resolved Hide resolved
@gartnera gartnera force-pushed the zetae2e-erc20-dynamic branch from 0a1acec to e94c9f8 Compare August 29, 2024 16:31
@gartnera gartnera added this pull request to the merge queue Aug 29, 2024
Merged via the queue into develop with commit 994f1ca Aug 29, 2024
29 checks passed
@gartnera gartnera deleted the zetae2e-erc20-dynamic branch August 29, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking:cli no-changelog Skip changelog CI check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants