Skip to content

refactor(e2e): make zetae2e balances chain-aware with --network flag#4558

Merged
ws4charlie merged 4 commits intomainfrom
e2e/chain-aware-balances
Mar 5, 2026
Merged

refactor(e2e): make zetae2e balances chain-aware with --network flag#4558
ws4charlie merged 4 commits intomainfrom
e2e/chain-aware-balances

Conversation

@ws4charlie
Copy link
Contributor

@ws4charlie ws4charlie commented Mar 2, 2026

Summary

  • Replace the --skip-btc boolean flag with a --network string flag that scopes native balance queries to a single external chain
  • Prevents cross-chain RPC failures (e.g. Sui "Index store not available") from crashing unrelated chain jobs in the parallel e2e workflow
  • ZEVM and EVM balances are always queried and printed (all cross-chain ops go through ZetaChain; EVM needed for gas diff reporting); external chain native balances are only fetched for the specified network
  • All network names are defined as constants to eliminate typo risk

Changes

File Change
e2e/runner/balances.go Add network constants (networkZEVM, networkPolygon, networkBSC, etc.); GetAccountBalances(skipBTC bool)GetAccountBalances(network string) with validation; PrintAccountBalances(balances)PrintAccountBalances(balances, network) with per-network gating; remove isEVMNetwork() helper (EVM always printed); always print EVM and TON balances consistently
cmd/zetae2e/balances.go Add --network flag (default "zevm"); deprecate+hide --skip-btc for backward compat
e2e/runner/run.go GetAccountBalances(true)GetAccountBalances(networkZEVM)

Before / After

Scenario Before After
Sui RPC down, running eth e2e job zetae2e balances --skip-btc queries Sui → panic zetae2e balances --network eth skips Sui → no crash
BTC e2e job zetae2e balances queries all chains zetae2e balances --network btc queries only BTC native
Default (no flag) Queries all external chains --network zevm → queries ZEVM + EVM only (safe default)
EVM balances display Only printed for EVM networks Always printed (always queried for gas reporting)

Supported --network values

Value What's queried
zevm (default) ZEVM + EVM balances only
polygon, bsc, eth, base, arbitrum, avalanche ZEVM + EVM native balances
btc ZEVM + EVM + BTC balance
solana ZEVM + EVM + SOL + SPL balances
sui ZEVM + EVM + SUI + SUI token balances
ton ZEVM + EVM + TON balance

Note: Requires a corresponding change in zt/e2e repo to pass --network ${network_to_test} instead of --skip-btc in reusable-e2e.yaml.

🤖 Generated with Claude Code

Replace the `--skip-btc` boolean flag with a `--network` string flag
that scopes native balance queries to a single external chain. This
prevents cross-chain RPC failures (e.g. Sui index store unavailable)
from crashing unrelated chain jobs in the parallel e2e workflow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

📝 Walkthrough

Walkthrough

This PR refactors the e2e balance query system from a boolean flag mechanism to a network-aware orchestration system. A new --network flag is introduced in the CLI, with the legacy --skip-btc flag deprecated for backward compatibility. The balance retrieval logic is restructured to support chain-specific queries (ZEVM, EVM, BTC, Solana, Sui, TON) based on the selected network parameter.

Changes

Cohort / File(s) Summary
CLI Interface and Documentation
changelog.md, cmd/zetae2e/balances.go
Adds changelog entry documenting network-aware balances. Introduces --network flag; deprecates and hides --skip-btc for backward compatibility with migration guidance. Updates GetAccountBalances call signature to pass network string instead of skipBTC boolean.
Balance Retrieval and Display Logic
e2e/runner/balances.go
Introduces network constants (btc, solana, sui, ton) and validation whitelist. Refactors GetAccountBalances signature from (skipBTC bool) to (network string) with network validation. Implements network-gated balance retrieval: ZEVM and EVM always queried, external chains (BTC, Solana, Sui, TON) fetched conditionally. Updates PrintAccountBalances signature to accept network parameter and gates balance display sections per active network using isEVMNetwork helper.
Balance Reporting Integration
e2e/runner/run.go
Updates pre- and post-test GetAccountBalances calls to pass empty string "" as network argument instead of boolean true.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the primary change: introducing a --network flag to make zetae2e balances chain-aware, replacing the boolean --skip-btc approach.
Description check ✅ Passed The pull request description is comprehensive and well-structured, covering objectives, changes, supported values, and before/after scenarios.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch e2e/chain-aware-balances

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ws4charlie
Copy link
Contributor Author

bugbot run

@ws4charlie ws4charlie added E2E E2E tests related test Tests related labels Mar 2, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: EVM balances no longer fetched for gas tracking reports
    • Changed GetAccountBalances("") to GetAccountBalances("eth") to restore EVM balance fetching for gas tracking, matching the pre-refactor behavior.

Create PR

Or push these changes by commenting:

@cursor push e985adb0dc
Preview (e985adb0dc)
diff --git a/e2e/runner/run.go b/e2e/runner/run.go
--- a/e2e/runner/run.go
+++ b/e2e/runner/run.go
@@ -101,7 +101,7 @@
 	reports := make(TestReports, 0, len(e2eTests))
 	for _, test := range e2eTests {
 		// get info before test
-		balancesBefore, err := r.GetAccountBalances("")
+		balancesBefore, err := r.GetAccountBalances("eth")
 		if err != nil {
 			return nil, err
 		}
@@ -117,7 +117,7 @@
 		time.Sleep(5 * time.Second)
 
 		// get info after test
-		balancesAfter, err := r.GetAccountBalances("")
+		balancesAfter, err := r.GetAccountBalances("eth")
 		if err != nil {
 			return nil, err
 		}
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

- Add validNetworks map to reject unknown --network values early
- Always query EVM balances (needed by GetAccountBalancesDiff for gas
  reporting in RunE2ETestsIntoReport); only gate printing on isEVMNetwork
- Add comment explaining --skip-btc is intentionally not read (lockstep
  CI update)
- Add changelog entry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ws4charlie ws4charlie marked this pull request as ready for review March 2, 2026 23:25
@ws4charlie ws4charlie requested a review from a team as a code owner March 2, 2026 23:25
Copy link
Member

@skosito skosito left a comment

Choose a reason for hiding this comment

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

some small comments

- Add constants for EVM network names (networkPolygon, networkBSC, etc.)
  and use them in validNetworks map to eliminate typo risk
- Remove isEVMNetwork helper (dead code after printing change)
- Always print EVM balances since they are always queried
- Remove inconsistent zero-check for TON balance printing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ring

- Add networkZEVM = "zevm" constant for the ZEVM-only default
- Update cobra flag default from "" to "zevm"
- Replace GetAccountBalances("") calls with GetAccountBalances(networkZEVM)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ws4charlie ws4charlie enabled auto-merge March 4, 2026 23:18
@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ws4charlie ws4charlie added this pull request to the merge queue Mar 5, 2026
Merged via the queue into main with commit 7f3e254 Mar 5, 2026
50 of 52 checks passed
@ws4charlie ws4charlie deleted the e2e/chain-aware-balances branch March 5, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking:cli E2E E2E tests related test Tests related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants