Skip to content

feat(e2e): cross-layer Rust↔contract test harness in crates/e2e (#1028) - #1053

Merged
yigitdot merged 5 commits into
mainfrom
worktree-feat+1028-e2e-harness
Jul 6, 2026
Merged

yigitdot merged 5 commits into
mainfrom
worktree-feat+1028-e2e-harness

Conversation

@yigitdot

@yigitdot yigitdot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

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.rs bring-up into reusable fixtures in a new test-only workspace member crates/e2e (publish = false, gated behind the anvil-e2e feature).

Fixtures

  • ChainFixture — spins up anvil (with a unique per-fixture chain id so concurrent fixtures never race on the deploy manifest), runs the production DeployProtocol forge script (with the Flaky anvil-e2e: forge script deploy 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 + registerNode with 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 real decdn-node daemon 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-signed stream_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 isActive on-chain → paid fetch delivers the exact 2 MiB blob → daemon admin reports the open channel → on-chain FeeRouter served-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/v1 serve path is store-only (origin pull-through isn't consulted on the direct client path), so NodeFixture pre-warms the store via CacheEngine + shutdown().

Review feedback addressed

Round 1 (d50c02f)

  • Manifest race (CodeRabbit, Major): each fixture now derives a unique chain_id = CHAIN_BASE + (port % 10_000) so the deployments/<chain_id>.json path 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.
  • TOML path escaping (Gemini High + CodeRabbit): path fields in the generated daemon config use single-quoted TOML literal strings so Windows backslashes/escapes round-trip.
  • smoke.rs (CodeRabbit): .expect(...) → .context(...)?; poll returns anyhow::Result<Option<T>> and propagates the real admin/chain error instead of swallowing it via .ok().

Round 2 (1e92f1a)

  • Fail fast on premature daemon exit (Gemini, 3 linked comments): NodeGuard now wraps std::sync::Mutex<Child> so wait_healthy(&self) can try_wait() each poll iteration and bail immediately with the exit status if decdn-node dies 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 every sleep().await.
  • Idiomatic smoke-test tail (Gemini): the outer timeout wrapper is now .context(...)??; followed by an explicit Ok(()), rather than returning the inner Result as 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_id collision (supersedes the Round-1 note): CHAIN_BASE + (port % 10_000) still collided for ephemeral ports 10 000 apart, so concurrent fixtures could clobber each other's deployments/<chain_id>.json and read the other anvil's addresses. Now CHAIN_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); the contracts/.gitignore glob is widened to deployments/31337[67]*.json for the new id band.
  • Silent reverts: alloy's get_receipt() resolves Ok on a mined-but-reverted tx, so every on-chain write (mint / transfer / approve / bond / registerNode / openChannel / createNamespace) now checks receipt.status() via a shared ensure_mined helper. Most exposed was create_namespace, which returned the static-call id unconditionally.
  • Conformance test: the one ungated channel_id test now pins an independent fixed keccak vector (cast keccak), so a wrong original packing is caught, not just a later refactor.
  • Doc/comment rot: removed the broken intra-doc link to a nonexistent OriginAssignment helper and the aspirational "impersonation targets" comment (rustdoc::broken_intra_doc_links); fixed the self-contradictory "in-process (subprocess)" daemon wording.
  • Polish: unit test for the forge broadcast-hiccup classifier; anvil bring-up fast-fails on premature child death; wait_healthy surfaces the last probe error; dead bondingNonce binding removed; free_port deduped to one crate helper; rendered log_level aligned to the daemon's RUST_LOG=warn; ClientFixture::address() added for client-side channel assertions.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a new end-to-end test crate and included it in the workspace.
    • Introduced reusable end-to-end fixtures for launching a local chain, running a node, and fetching delivered bytes.
    • Added contract ABI bindings and assertion helpers used by the test suite.
    • Added time-control utilities for local test chains.
    • Added an anvil-e2e-gated smoke test that validates a full happy-path delivery flow.
  • Bug Fixes
    • Improved end-to-end test robustness (retries/timeouts) and expanded ignored deployment-manifest patterns for test-chain cleanup.

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]>
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 86dc961f-802d-449f-a6b7-26fec9a108d5

📥 Commits

Reviewing files that changed from the base of the PR and between 0832c1e and 5e9c47d.

📒 Files selected for processing (1)
  • crates/e2e/src/assert.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/e2e/src/assert.rs

Walkthrough

Adds 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.

Changes

e2e fixture crate

Layer / File(s) Summary
Workspace wiring and crate root
Cargo.toml, crates/e2e/Cargo.toml, crates/e2e/src/lib.rs, contracts/.gitignore
Adds crates/e2e to the workspace, defines the new crate manifest, exports the fixture modules, and broadens the test deployment-manifest ignore pattern.
Contract bindings, assertions, and time control
crates/e2e/src/bindings.rs, crates/e2e/src/assert.rs, crates/e2e/src/time.rs
Defines the e2e contract interfaces and adds helpers for reading channel state, checking operator activity, deriving channel ids, reading client nonces, and advancing Anvil time.
Chain fixture and deployment flow
crates/e2e/src/chain.rs
Implements Anvil launch, protocol deployment, contract address discovery, operator onboarding, namespace setup, served-bytes reads, and supporting deployment utilities.
Node fixture and daemon startup
crates/e2e/src/node.rs
Adds the node fixture, subprocess guard, config rendering, origin blob seeding, admin health polling, binary resolution, and port allocation.
Paid client fixture
crates/e2e/src/client.rs
Adds the paid-client fixture, channel opening and retrying fetch flow, payload verification, and loopback endpoint setup.
End-to-end smoke test
crates/e2e/tests/smoke.rs
Adds a feature-gated smoke test and poll helper that exercise the full chain-node-client flow.

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

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: a new cross-layer e2e test harness in crates/e2e.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-feat+1028-e2e-harness

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

@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 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.

Comment thread crates/e2e/src/node.rs Resolved
@github-actions

github-actions Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.09% (was 83.20%, ▼ 1.11%) — 41975/51134 lines

File Coverage Lines Δ
crates/e2e/src/assert.rs 32.08% 17/53 new
crates/e2e/src/chain.rs 3.06% 11/359 new
crates/e2e/src/client.rs 0.00% 0/106 new
crates/e2e/src/lib.rs 0.00% 0/11 new
crates/e2e/src/node.rs 0.00% 0/160 new
crates/e2e/src/time.rs 0.00% 0/28 new
History
Commit Total Δ vs base
ebee3f6 82.12% ▼ 1.07%
d50c02f 82.11% ▼ 1.08%
1e92f1a 82.10% ▼ 1.10%
0832c1e 82.09% ▼ 1.11%
5e9c47d (HEAD) 82.09% ▼ 1.11%

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8f51f4b and ebee3f6.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (10)
  • Cargo.toml
  • crates/e2e/Cargo.toml
  • crates/e2e/src/assert.rs
  • crates/e2e/src/bindings.rs
  • crates/e2e/src/chain.rs
  • crates/e2e/src/client.rs
  • crates/e2e/src/lib.rs
  • crates/e2e/src/node.rs
  • crates/e2e/src/time.rs
  • crates/e2e/tests/smoke.rs

Comment thread crates/e2e/src/chain.rs Resolved
Comment thread crates/e2e/src/node.rs Resolved
Comment thread crates/e2e/tests/smoke.rs Resolved
Comment thread crates/e2e/tests/smoke.rs Resolved
- 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]>

@coderabbitai coderabbitai 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.

♻️ Duplicate comments (1)
crates/e2e/src/chain.rs (1)

27-33: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Use 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/.gitignore from deployments/3133769*.json to deployments/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

📥 Commits

Reviewing files that changed from the base of the PR and between ebee3f6 and d50c02f.

📒 Files selected for processing (4)
  • crates/e2e/src/chain.rs
  • crates/e2e/src/client.rs
  • crates/e2e/src/node.rs
  • crates/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

@yigitdot

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 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.

Comment thread crates/e2e/src/node.rs Resolved
Comment thread crates/e2e/src/node.rs Resolved
Comment thread crates/e2e/src/node.rs Resolved
Comment thread crates/e2e/tests/smoke.rs Resolved
- 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]>
@yigitdot
yigitdot requested a review from alpergundogdu July 3, 2026 17:12
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]>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 90.87% (2289/2519 lines)
▲ +0.00pp vs base (90.87% → 90.87%)
Run: 28686444459

Copy link
Copy Markdown
Contributor

PR #1053 Review Fix Plan

Summary

  • Replace ClientFixture::fetch’s broad stream_fetch retry loop with an explicit “channel observed by daemon” wait before delivery.
  • Harden NodeFixture config rendering so TOML escaping is handled structurally instead of by string interpolation.
  • Keep fixture public APIs unchanged; no production protocol/runtime behavior changes.

Key Changes

  • In crates/e2e/src/client.rs, after openChannel is mined and channel_id is derived, poll node.admin_client()?.channels() until a snapshot has channel_id == cid.to_string(), with the existing 45s budget and contextual admin errors.
  • Call stream_fetch once after that readiness wait. Do not retry arbitrary delivery errors; post-readiness failures should surface directly instead of being masked or retried with stale voucher state.
  • In crates/e2e/tests/smoke.rs, make the admin channel assertion check for outcome.channel_id specifically rather than only “any channel exists”.
  • In crates/e2e/src/node.rs, replace handwritten TOML string assembly with toml::Table / toml::Value rendering. Refactor RenderConfig to carry chain_id and ContractAddrs directly so rendering can be unit-tested without launching fixtures.

Tests

  • Add a unit test for config rendering that uses paths containing backslashes and apostrophes, parses the rendered TOML, and asserts the original values round-trip.
  • Run:
    • cargo test -p decdn-e2e --no-default-features --locked
    • cargo clippy -p decdn-e2e --all-targets -- -D warnings
    • cargo fmt --check
    • cargo build -p decdn-node && cargo nextest run -p decdn-e2e --features anvil-e2e

Assumptions

  • The readiness source of truth is admin_v1_channels, since it reflects the daemon watcher having persisted ChannelOpened.
  • A delivery failure after readiness is a real test failure, not a watcher catch-up race.
  • I could not run Cargo verification locally: offline mode lacked cached arc-swap 1.9.2, and network-enabled Cargo was rejected because it would run PR-controlled code with network access.

…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]>
@yigitdot

yigitdot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Checked this against the current branch — technically sound, and I verified the central design point: gating the first stream_fetch on admin channels() reporting the channel does not deadlock. The watcher's ChannelOpened handler (register_open_channel, crates/node/src/handlers/client.rs:749) persists the channel to the store channels() reads and inserts it into the in-memory map that gates serve_get (client.rs:1189) in the same call, so readiness and delivery-acceptance become true together.

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 — channels() reads the persisted store while serve_get reads the in-memory map, and although both are written by register_open_channel, dropping all retry also removes the cushion for ordinary network flakiness.

thiras added a commit that referenced this pull request Jul 12, 2026
, #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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

e2e harness: cross-layer Rust↔contract test fixtures (crates/e2e)

3 participants