Repository navigation
test(e2e): harden fixtures — retries, exact assertions, accessors (#1061, #1063, #1064, #1065, #1066) - #1127
Conversation
, #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]>
|
Warning Review limit reached
Next review available in: 51 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (2)
WalkthroughE2E 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. ChangesE2E fixture reliability and API updates
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
Note 🎁 Summarized by CodeRabbit FreeYour 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 |
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 88.71% (2452/2764 lines) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Coverage reportTotal: 80.25% (was 80.30%, ▼ 0.06%) — 45010/56089 lines
History
|
…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]>
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
forge_buildgets a bounded retry (mirrorsrun_deploy_script) and the cap is raised 180s → 300s. A timeout retries; a real compile error still fails fast with diagnostics.free_ports::<N>()binds N listeners simultaneously so the node's three ports are guaranteed distinct (sequential grabs could repeat).ChainFixture::launchnow re-picks the ephemeral port and re-spawns when anvil dies at startup — thefree_portTOCTOU that also seedschain_id. The residual (SO_REUSEADDR fd-handoff, unavailable because anvil/decdn-nodecan't inherit a listener) is documented.#[cfg(test)]test parsesrender_config's output as TOML, so a malformed template is caught in normalcargo nextest run -p decdn-e2ewithout Foundry.RenderConfigwas decoupled from the wholeChainFixture(now takeschain_id+addrs) to make this testable.outcome.channel_id, plus counterparty and deposit), and that on-chain served-bytes equals the exact delivered payload size — not merely> 0.ChainFixture/NodeFixturedescriptivepubfields becomepub fnaccessors (andrpc_url/urlcollapse to one stored form), so alet mut fixtureauthor can't reassign a field and silently desync the fixture from the live process it describes.Verification
cargo fmt -p decdn-e2e -- --check— cleancargo clippy --workspace --all-targets(-D warnings) — cleancargo nextest run -p decdn-e2e— ungated unit tests pass (incl. the newrender_configparse 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
Tests
API Improvements