Skip to content

test(e2e): harden fixtures — retries, exact assertions, accessors (#1061, #1063, #1064, #1065, #1066) - #1127

Merged
thiras merged 2 commits into
mainfrom
fix/e2e-fixture-hardening-batch
Jul 12, 2026
Merged

thiras merged 2 commits into
mainfrom
fix/e2e-fixture-hardening-batch

Conversation

@thiras

@thiras thiras commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

What & why

A batch of five e2e test-fixture hardening follow-ups, all deliberately deferred as low-urgency items from the multi-agent review of #1053. All five live entirely inside crates/e2e/, are independent, and share one origin — making them a clean single-PR batch.

They split into two kinds:

Changes

Verification

  • cargo fmt -p decdn-e2e -- --check — clean
  • cargo clippy --workspace --all-targets (-D warnings) — clean
  • cargo nextest run -p decdn-e2e — ungated unit tests pass (incl. the new render_config parse test)
  • cargo nextest run -p decdn-e2e --features anvil-e2e --test-threads 2 — 9/9 pass against real anvil chains, exercising every accessor path plus the anvil-retry / forge-build changes. e2e: tighten smoke-test assertions (exact served-bytes, channel_id membership) #1063's exact served-bytes and channel-match assertions were confirmed against a live redeem (no guessed constants).

Closes #1061
Closes #1063
Closes #1064
Closes #1065
Closes #1066

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Reliability Improvements

    • Improved end-to-end test startup by retrying transient build timeouts and local service launch failures.
    • Enhanced diagnostics for deterministic build failures.
    • Reduced port-collision risk during test setup.
  • Tests

    • Strengthened smoke-test checks for channel identity, counterparty, deposit amount, and exact delivery totals.
    • Added validation that generated node configuration is valid and contains expected settings.
  • API Improvements

    • Standardized access to chain and node runtime information through stable accessor methods.

, #1063, #1064, #1065, #1066)

Batch of five hardening follow-ups deferred from the #1053 review, all within
crates/e2e/:

- #1066: give forge_build a bounded retry (mirrors run_deploy_script) and raise
  the cap 180s→300s. A timeout retries; a real compile error still fails fast.
- #1065: bind N ephemeral ports simultaneously via free_ports::<N>() so the
  node's three ports are guaranteed distinct, and re-pick the anvil port when
  anvil dies at startup (the free_port TOCTOU that also seeds chain_id).
- #1064: add an ungated render_config TOML-parse unit test (decoupling
  RenderConfig from ChainFixture) so a template regression is caught in normal
  CI without Foundry.
- #1063: assert the daemon reports the exact channel we paid through (match
  outcome.channel_id, counterparty, deposit) and that on-chain served-bytes
  equals the exact delivered payload size, not merely > 0.
- #1061: convert ChainFixture/NodeFixture descriptive pub fields to accessors
  (collapsing rpc_url/url to one stored form) so a fixture can't be silently
  desynced from the live process it describes.

Verified: cargo fmt --check, workspace clippy -D warnings, ungated unit tests,
and the full `--features anvil-e2e` suite (9/9) against real anvil chains.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 12, 2026 21:14
@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@thiras, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 609ef741-d346-417a-8295-c3addb5c3e2a

📥 Commits

Reviewing files that changed from the base of the PR and between 60dc5ea and 7aea989.

📒 Files selected for processing (2)
  • crates/e2e/src/chain.rs
  • crates/e2e/src/node.rs

Walkthrough

E2E fixtures now retry transient build and anvil startup failures, allocate ports in coordinated batches, expose immutable runtime facts through accessors, and pass explicit chain configuration. Tests adopt the new APIs and strengthen channel, balance, and served-bytes assertions.

Changes

E2E fixture reliability and API updates

Layer / File(s) Summary
Chain startup and build retries
crates/e2e/src/chain.rs
Forge builds retry timeouts, anvil startup retries across ports, and ChainFixture runtime fields are replaced with accessor methods.
Port allocation and node configuration
crates/e2e/src/lib.rs, crates/e2e/src/node.rs
Multiple ephemeral ports are reserved together, node configuration receives explicit chain coordinates, and rendered TOML is validated.
Client fixture accessor migration
crates/e2e/src/client.rs
Payment-channel, voucher, probe, and deposit setup use the new chain and node accessors.
E2E wiring and stronger assertions
crates/e2e/tests/cli_fetch_topup.rs, crates/e2e/tests/g_node_04_blacklist_compliance.rs, crates/e2e/tests/slash_appeal.rs, crates/e2e/tests/smoke.rs
Tests use accessor-based fixture APIs and add exact channel, deposit, served-bytes, balance, and appeal-state checks.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ChainFixture
  participant forge
  participant anvil
  participant RPC
  ChainFixture->>forge: Run forge build with bounded retries
  forge-->>ChainFixture: Return build result
  ChainFixture->>anvil: Launch on an ephemeral port
  anvil-->>ChainFixture: Report process status
  ChainFixture->>RPC: Poll get_chain_id()
  RPC-->>ChainFixture: Return reachable chain identity
Loading

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 88.71% (2452/2764 lines)
▲ +0.00pp vs base (88.71% → 88.71%)
Run: 29209517274

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the crates/e2e/ test harness to reduce flakes and increase assertion precision, while tightening fixture invariants by replacing mutable descriptive pub fields with accessors. It also adds a cheap ungated unit test to catch TOML template regressions without requiring Foundry/anvil.

Changes:

  • Improve robustness: retry/timeout behavior for forge build, retry anvil bring-up on early exit, and allocate multiple distinct ephemeral ports in one grab.
  • Improve test quality: smoke test asserts exact channel identity/deposit and exact served-bytes accounting.
  • Harden fixtures: convert ChainFixture/NodeFixture descriptive fields into accessors and add an ungated TOML-parse unit test for render_config.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/e2e/src/chain.rs Adds anvil bring-up retry and forge build bounded retry/timeout increase; converts ChainFixture fields to accessors.
crates/e2e/src/lib.rs Introduces free_ports::<N>() to reserve multiple distinct ephemeral ports together; keeps free_port() wrapper.
crates/e2e/src/node.rs Converts NodeFixture fields to accessors, uses free_ports::<3>(), decouples RenderConfig, and adds TOML-parse unit test for the rendered template.
crates/e2e/src/client.rs Exposes DEPOSIT_MICRO_USDC for exact assertions and updates call sites to new accessors.
crates/e2e/tests/smoke.rs Tightens cross-layer assertions (exact channel match + exact served-bytes) and updates to fixture accessors.
crates/e2e/tests/slash_appeal.rs Updates to fixture accessor APIs and admin/provider accessors.
crates/e2e/tests/g_node_04_blacklist_compliance.rs Updates to fixture accessor APIs for chain/node fields.
crates/e2e/tests/cli_fetch_topup.rs Updates to chain accessors for addresses/usdc/chain_id.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/e2e/src/node.rs Resolved
Comment thread crates/e2e/src/chain.rs Resolved
Comment thread crates/e2e/src/chain.rs Resolved

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the E2E test fixtures (ChainFixture and NodeFixture) by encapsulating previously public fields behind read-only accessor methods to prevent accidental desynchronization. It also hardens the test suite against transient CI failures and port collisions by implementing simultaneous ephemeral port allocation (free_ports), retrying anvil startup on port collisions, and retrying forge build on timeouts. Additionally, a unit test was added for daemon configuration rendering, and assertions in the smoke tests were made more precise. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.25% (was 80.30%, ▼ 0.06%) — 45010/56089 lines

File Coverage Lines Δ
crates/e2e/src/chain.rs 1.46% 11/752 ▼ 0.07%
crates/e2e/src/client.rs 0.00% 0/146 ● 0.00%
crates/e2e/src/lib.rs 0.00% 0/21 ● 0.00%
crates/e2e/src/node.rs 19.31% 50/259 ▲ +19.31%
History
Commit Total Δ vs base
60dc5ea 80.25% ▼ 0.05%
7aea989 (HEAD) 80.25% ▼ 0.06%

…ssages

- node.rs: bind `chain.rpc_url()` to a local before RenderConfig so the `&str`
  field borrows a value outliving the render_config call, not a same-statement
  temporary (robust against a later `let cfg = ...` refactor).
- chain.rs: reword the anvil premature-exit warn and the exhausted-retries bail
  to state observed behavior (exited before RPC came up) instead of asserting a
  port collision as the root cause, which can mislead debugging.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras merged commit 4c94b32 into main Jul 12, 2026
23 checks passed
@thiras
thiras deleted the fix/e2e-fixture-hardening-batch branch July 12, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants