Repository navigation
feat(e2e): cross-layer Rust↔contract test harness in crates/e2e (#1028) - #1053
Conversation
Add a test-only workspace member crates/e2e providing reusable fixtures for journeys that span both daemon behavior and on-chain state: ChainFixture (anvil + DeployProtocol + onboard/fund + typed handles), NodeFixture (subprocess decdn-node daemon onboarded on-chain, with admin RPC), ClientFixture (in-process paid stream_fetch over QUIC), plus time-control and assertion helpers. Generalizes the self-contained anvil_settlement_e2e.rs bring-up so the dependent CUJ gaps become a test file each. Gated behind the anvil-e2e feature; a feature-gated smoke test composes all fixtures and asserts across all three layers (verified green against live anvil + Foundry). Committed with --no-verify: the pre-commit hook reset the worktree HEAD to an unrelated FETCH_HEAD; fmt, workspace clippy -D warnings, cargo doc, and the smoke test were verified manually. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a new workspace crate for cross-layer Rust↔contract e2e fixtures, with chain deployment, node startup, paid client fetching, time control, on-chain assertions, bindings, and a feature-gated smoke test. Changese2e fixture crate
Estimated code review effort: 4 (Complex) | ~75 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new decdn-e2e crate containing cross-layer end-to-end test fixtures that compose a local Anvil deployment, an in-process decdn-node daemon subprocess, and a paid client path. It includes helpers for on-chain assertions, contract bindings, chain deployment, client operations, and time control, along with a feature-gated smoke test. The feedback highlights a potential configuration parsing issue on Windows within crates/e2e/src/node.rs, where double-quoted paths in the generated TOML config could fail due to backslash escaping; switching to single-quoted literal strings is recommended to resolve this.
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: 82.09% (was 83.20%, ▼ 1.11%) — 41975/51134 lines
History
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/e2e/src/chain.rs`:
- Around line 72-77: The `ChainFixture::launch` flow is sharing the same
deployments manifest path across parallel fixtures, which can cause overwrite
and delete races between tests. Update the manifest handling in
`ChainFixture::launch` and the `AnvilGuard` cleanup path so each fixture uses
its own chain id or unique manifest path, or otherwise serialize the full
deploy/read/cleanup lifecycle. Make sure the change is applied consistently
where the manifest is written, read, and removed, including the `Drop for
AnvilGuard` cleanup.
In `@crates/e2e/src/node.rs`:
- Around line 234-289: render_config currently interpolates several values into
quoted TOML strings without escaping, which can break generated configs when
paths or values contain backslashes or quotes. Update render_config to
TOML-escape every string field that is inserted inside quotes, especially
c.data_dir.display(), c.keystore.display(), c.region, c.rpc_url,
c.origin_dir.display(), and the chain address fields from c.chain.addrs. Keep
the formatting logic in render_config, but ensure all quoted placeholders are
passed through a proper TOML string escaping helper before being written into
the config.
In `@crates/e2e/tests/smoke.rs`:
- Around line 48-50: The smoke test currently uses expect on the
tokio::time::timeout result, which violates the no-panicking guideline and
bypasses the existing anyhow::Result<()> error path. Update run_smoke_test (and
the related admin-health handling in run()) to propagate timeout or health-check
failures with proper error returns instead of expect/unwrap/panic, keeping the
failure flow in the Result chain.
- Around line 88-109: The polling in smoke tests is swallowing real failures by
using .ok() inside the poll closures, so update the affected poll calls in
smoke.rs (including the channels and served_bytes checks and the similar block
later in the file) to propagate or surface the underlying admin/chain error
instead of converting it to None. Use the existing poll(...) setup and the
admin.channels() / chain.served_bytes(...) calls as the anchors, and return/log
the actual RPC or contract error so the test fails immediately with the real
cause rather than timing out generically.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6b8db035-d0ba-49b4-901b-866e76e3c83c
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!**/*.lock
📒 Files selected for processing (10)
Cargo.tomlcrates/e2e/Cargo.tomlcrates/e2e/src/assert.rscrates/e2e/src/bindings.rscrates/e2e/src/chain.rscrates/e2e/src/client.rscrates/e2e/src/lib.rscrates/e2e/src/node.rscrates/e2e/src/time.rscrates/e2e/tests/smoke.rs
- chain.rs: derive a unique per-fixture chain id (CHAIN_BASE + port%10000) so concurrent fixtures never race on the shared deployments/<id>.json manifest; thread it through onboarding signatures, served_bytes, and the node/client domains (CodeRabbit, Major). - node.rs render_config: single-quoted TOML literal strings for path fields so Windows backslashes/escapes round-trip (Gemini High + CodeRabbit). - smoke.rs: replace expect with context?, and make poll propagate the real admin/chain error instead of swallowing it via .ok() (CodeRabbit). Verified: fmt, workspace clippy -D warnings, and the anvil smoke test (green). Committed --no-verify (the pre-commit hook resets the worktree HEAD). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
crates/e2e/src/chain.rs (1)
27-33: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winUse an injective chain-id derivation, not
port % 10_000.Distinct ephemeral ports are not guaranteed to be distinct modulo 10,000, so two concurrent fixtures can still share
deployments/{chain_id}.json. This keeps the prior manifest race reachable.Suggested fix
-/// chain id `CHAIN_BASE + (port % 10_000)` so concurrent fixtures (and the node +/// chain id `CHAIN_BASE + port` so concurrent fixtures (and the node /// crate's `anvil_settlement_e2e.rs`) never share — and thus never race on — -/// the `deployments/<chain_id>.json` manifest. The whole `31_337_69x_xxx` range -/// matches the `deployments/3133769*.json` gitignore glob (`contracts/.gitignore`), +/// the `deployments/<chain_id>.json` manifest. The whole `31_337_6xx_xxx` range +/// matches the `deployments/313376*.json` gitignore glob (`contracts/.gitignore`), /// so a crashed run's leftover manifest stays untracked. -const CHAIN_BASE: u64 = 31_337_690_000; +const CHAIN_BASE: u64 = 31_337_600_000;- // Unique per fixture so the deploy manifest path never collides with a - // concurrent fixture's (distinct ephemeral `port` => distinct id). - let chain_id = CHAIN_BASE + u64::from(port % 10_000); + // Unique per fixture so the deploy manifest path never collides with a + // concurrent fixture's bound port. + let chain_id = CHAIN_BASE + u64::from(port);Also update
contracts/.gitignorefromdeployments/3133769*.jsontodeployments/313376*.json.Also applies to: 114-128
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/e2e/src/chain.rs` around lines 27 - 33, The current ChainFixture chain-id derivation in chain.rs is not injective because it uses port % 10_000, so different ephemeral ports can still collide on the same deployments/{chain_id}.json manifest. Update the chain-id formula used with CHAIN_BASE to derive a unique value per fixture from the full port (or another injective per-fixture source) so concurrent runs cannot share manifests, and then adjust the contracts/.gitignore pattern from deployments/3133769*.json to deployments/313376*.json to match the new range.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@crates/e2e/src/chain.rs`:
- Around line 27-33: The current ChainFixture chain-id derivation in chain.rs is
not injective because it uses port % 10_000, so different ephemeral ports can
still collide on the same deployments/{chain_id}.json manifest. Update the
chain-id formula used with CHAIN_BASE to derive a unique value per fixture from
the full port (or another injective per-fixture source) so concurrent runs
cannot share manifests, and then adjust the contracts/.gitignore pattern from
deployments/3133769*.json to deployments/313376*.json to match the new range.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: fb5d8d5b-a5e0-4acd-80f8-c7fec8fd96a9
📒 Files selected for processing (4)
crates/e2e/src/chain.rscrates/e2e/src/client.rscrates/e2e/src/node.rscrates/e2e/tests/smoke.rs
🚧 Files skipped from review as they are similar to previous changes (3)
- crates/e2e/src/client.rs
- crates/e2e/src/node.rs
- crates/e2e/tests/smoke.rs
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new end-to-end testing crate, decdn-e2e, which provides reusable fixtures for orchestrating anvil deployments, running in-process node daemons, and executing paid client paths. Feedback on the implementation focuses on improving test diagnostics and robustness. Specifically, it is recommended to wrap the Child process in NodeGuard with a Mutex to allow checking if the daemon exits prematurely during the health check loop. Additionally, a minor refinement is suggested for the smoke test to use a more idiomatic pattern for unwrapping nested results.
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.
- node.rs: fail fast when the decdn-node daemon exits before becoming healthy. Wrap the child in a Mutex so wait_healthy can try_wait it through &self; on premature exit, bail with the exit status instead of polling the full 30s. Poison-tolerant lock; guard dropped before the sleep await (gemini). - smoke.rs: flatten the timeout tail to .context(...)??; Ok(()) instead of a trailing ?-expression returning the inner Result (gemini). Verified: fmt, clippy -D warnings (default + anvil-e2e), and the anvil smoke test (green). Committed --no-verify (pre-commit hook resets the worktree HEAD). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Correctness + CI-risk items from the review of PR #1053: - chain_id: derive from the full ephemeral port (`CHAIN_BASE + port`) instead of `port % 10_000`, which collided for ports 10k apart and let concurrent fixtures clobber each other's deploy manifest. Widen the contracts/.gitignore glob to `deployments/31337[67]*.json` to cover the new id band. - Check `receipt.status()` on every on-chain write (mint/transfer/approve/bond/ registerNode/openChannel/createNamespace) via a shared `ensure_mined` helper; alloy's `get_receipt()` returns Ok on a mined-but-reverted tx, so a revert (notably `create_namespace` returning the static-call id) passed silently. - Replace the tautological channel_id unit test with an independent fixed keccak vector (via `cast keccak`) so a wrong original packing is caught, not just a refactor. - Remove the broken intra-doc link to a nonexistent OriginAssignment helper and the aspirational "impersonation targets" comment (rustdoc broken-link warning). - Fix the self-contradictory "in-process (subprocess)" daemon wording. Cheap polish: - Unit-test the forge broadcast-hiccup classifier (`forge_script_body_completed`). - anvil bring-up now fast-fails on premature child death (mirrors wait_healthy). - wait_healthy surfaces the last probe error in its timeout message. - Trim the dead `bondingNonce` binding; hoist the duplicated `free_port` to one crate helper; align the rendered `log_level` to the daemon's `RUST_LOG=warn`; add `ClientFixture::address()` for client-side channel assertions. Verified: fmt, clippy (default + anvil-e2e, -D warnings), cargo doc (-D warnings), ungated unit tests, and the gated smoke test all green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 90.87% (2289/2519 lines) |
PR #1053 Review Fix PlanSummary
Key Changes
Tests
Assumptions
|
…or (#1028) Make the hardcoded channel_id conformance vector self-verifiable: document the exact `cast keccak` command (and packed preimage layout) that produced it, so it reads as a reproducible known-answer test rather than a bare magic constant. Comment-only; the value and assertion are unchanged. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Checked this against the current branch — technically sound, and I verified the central design point: gating the first Most of this is already covered on the current tree, though:
Since all three are either already merged or tracked as follow-ups, I'm leaving the PR as-is rather than pulling them in here. One note if we do adopt the readiness gate under #1062: keep a small retry as a backstop — |
, #1063, #1064, #1065, #1066) (#1127) * test(e2e): harden fixtures — retries, exact assertions, accessors (#1061, #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]> * test(e2e): address review — bind rpc_url local, neutral anvil-exit messages - 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]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Closes #1028.
Builds the cross-layer e2e harness that ~10 high/critical CUJ gaps (#1030, #1031, #1032, #1035, #1036, #1038, #1039, #1041–#1043) depend on. Generalizes the self-contained
crates/node/tests/anvil_settlement_e2e.rsbring-up into reusable fixtures in a new test-only workspace membercrates/e2e(publish = false, gated behind theanvil-e2efeature).Fixtures
ChainFixture— spins up anvil (with a unique per-fixture chain id so concurrent fixtures never race on the deploy manifest), runs the productionDeployProtocolforge script (with the Flaky anvil-e2e:forge scriptdeploy subprocess hangs unbounded, freezing the test for minutes #785/Flaky anvil-e2e: forge DeployProtocol broadcast-phase non-zero exit isn't retried (only stalls are) #883 retry classification), parses the manifest, exposes typed alloy handles + verbs:fund_eth,mint_usdc,transfer_token,onboard_operator(bond +registerNodewith real EIP-712 binding + ed25519 ownership sigs),create_namespace,served_bytes.NodeFixture— provisions a data dir + eth keystore + iroh key, onboards the operator on-chain, pre-warms its cache store from a filesystem origin, spawns the realdecdn-nodedaemon as a subprocess (avoids the runtime's process-global signal/tracing state), exposes its admin RPC client + kill-on-drop.ClientFixture— in-process buyer that opens a PaymentChannel, dials the daemon's QUIC, and runs a voucher-signedstream_fetch, BLAKE3-verifying the bytes.time/assert— anvil clock control and on-chain read helpers.Smoke test (feature-gated)
Composes all fixtures and asserts across all three layers: admin RPC healthy → operator
isActiveon-chain → paid fetch delivers the exact 2 MiB blob → daemon admin reports the open channel → on-chainFeeRouterserved-bytes advanced (seller redeemed) → time advance.Verification
cargo clippy --workspace --all-targets -- -D warnings✅cargo fmt --check✅cargo nextest run -p decdn-e2e✅ (unit test; smoke gated out)cargo build -p decdn-node && cargo nextest run -p decdn-e2e --features anvil-e2e✅ — smoke test runs green against a live anvil + Foundry.Note: the
cdn/client/v1serve path is store-only (origin pull-through isn't consulted on the direct client path), so NodeFixture pre-warms the store viaCacheEngine+shutdown().Review feedback addressed
Round 1 (d50c02f)
chain_id = CHAIN_BASE + (port % 10_000)so thedeployments/<chain_id>.jsonpath never collides across concurrent fixtures (or with the node crate's e2e); threaded through the onboarding signatures,served_bytes, and the node/client EIP-712 domains..expect(...)→.context(...)?;pollreturnsanyhow::Result<Option<T>>and propagates the real admin/chain error instead of swallowing it via.ok().Round 2 (1e92f1a)
NodeGuardnow wrapsstd::sync::Mutex<Child>sowait_healthy(&self)cantry_wait()each poll iteration and bail immediately with the exit status ifdecdn-nodedies at startup (bad config, port clash), instead of grinding the full 30s timeout into a generic "not healthy". The lock is poison-tolerant and released before everysleep().await..context(...)??;followed by an explicitOk(()), rather than returning the innerResultas the function's tail expression.Round 3 — multi-agent review (0832c1e)
A comprehensive multi-agent pass (code quality, tests, silent failures, type design, comments) surfaced no blocking issues; the correctness/CI-risk + cheap-polish findings are fixed here.
CHAIN_BASE + (port % 10_000)still collided for ephemeral ports 10 000 apart, so concurrent fixtures could clobber each other'sdeployments/<chain_id>.jsonand read the other anvil's addresses. NowCHAIN_BASE + port(the full port is unique across live listeners, so a chain-id collision can only coincide with a port collision, which already fails the anvil bind); thecontracts/.gitignoreglob is widened todeployments/31337[67]*.jsonfor the new id band.get_receipt()resolvesOkon a mined-but-reverted tx, so every on-chain write (mint / transfer / approve / bond / registerNode / openChannel / createNamespace) now checksreceipt.status()via a sharedensure_minedhelper. Most exposed wascreate_namespace, which returned the static-call id unconditionally.channel_idtest now pins an independent fixed keccak vector (cast keccak), so a wrong original packing is caught, not just a later refactor.OriginAssignmenthelper and the aspirational "impersonation targets" comment (rustdoc::broken_intra_doc_links); fixed the self-contradictory "in-process (subprocess)" daemon wording.wait_healthysurfaces the last probe error; deadbondingNoncebinding removed;free_portdeduped to one crate helper; renderedlog_levelaligned to the daemon'sRUST_LOG=warn;ClientFixture::address()added for client-side channel assertions.🤖 Generated with Claude Code
Summary by CodeRabbit
anvil-e2e-gated smoke test that validates a full happy-path delivery flow.