Skip to content

test(node): node-to-node pull-through sad-path coverage (#746) - #827

Merged
thiras merged 1 commit into
mainfrom
test/node-to-node-pull-through-sad-paths-746
Jun 6, 2026
Merged

thiras merged 1 commit into
mainfrom
test/node-to-node-pull-through-sad-paths-746

Conversation

@thiras

@thiras thiras commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes the remaining in-scope portion of #746. The happy-path two-hop integration test landed in #813; this adds the three sad-path cdn/client/v1 node-to-node fault cases the issue triage called out. All three are real in-process iroh exchanges on localhost with off-chain vouchers — no anvil, no RPC, no contract — and no production code changed.

Test Models Asserts
upstream_channel_open_failure_pull_fails_cleanly Upstream unreachable / channel-open fails — a peer that accepts the QUIC connection then immediately closes it (a deterministic, ms-fast stand-in for a dead UDP port, whose ICMP-vs-timeout behavior would be flaky) stream_fetch returns a clean Err that fails fast (not a hang to the deadline); the fake upstream is joined so its panics surface
client_disconnect_mid_stream_leaves_channel_reusable A client of the real ClientHandler reads the response + one chunk, then aborts before paying (1) no voucher/accounting committed — nonce and bytes-delivered stay zero; (2) the same channel is immediately reusable by an honest pull, proving the serial accept loop recovered with no poisoned lock or dangling delivery state
upstream_hash_mismatch_is_rejected A protocol-correct but dishonest upstream (valid signed response, paid + ack'd voucher, clean StreamEnd) serving bytes that hash to the wrong value The requester's whole-blob BLAKE3 check rejects the delivery (exact error string pinned), never surfacing corrupt bytes — guarding content-addressing across a paid hop

The reusable raw framed-message primitives (read_client_msg, write_client_msg, accept_one) are promoted into tests/support so the other cdn/client/v1 binaries can share them; only the test-specific lying_upstream fake server stays local to the binary.

Scope / boundary

This is the test half of #746. The full automatic flow #746 envisions — a node auto-opening an upstream channel on cache miss and streaming through — still does not exist in the runtime (no NodeOrigin; the cache-engine hook that would call open_or_reuse_channel is deferred on provider discovery, ADR 001/022, alongside the DHT effort). That orchestration is separate follow-up work and is not asserted here.

Review

These tests were put through the pr-review-toolkit (test-coverage, code-review, comment-accuracy, silent-failure). The one material finding — test 1's original is_err()-only assertion plus a bare refuser.abort() couldn't distinguish a correctly-surfaced refusal from a timeout or a swallowed panic — is addressed in this PR (fast-failure assertion + clean task join). Secondary suggestions (shared-module placement of helpers, an extra bytes-delivered assertion) are also incorporated.

Verification

  • cargo fmt -- --check: clean
  • cargo clippy -p decdn-node --tests: no warnings (anti-panic policy satisfied)
  • cargo nextest run -p decdn-node: 510/510 pass
  • New sad-path binary run repeatedly: deterministic, no flakiness

🤖 Generated with Claude Code

The two-hop pull-through binary only covered the happy path. Add the
three `cdn/client/v1` node-to-node fault cases #746 called out, all as
real in-process iroh exchanges with off-chain vouchers:

- `upstream_channel_open_failure_pull_fails_cleanly`: an upstream that
  accepts then immediately closes the connection (a deterministic,
  fast stand-in for an unreachable peer) — asserts `stream_fetch`
  surfaces a clean, fast `Err`, not a hang to the deadline.
- `client_disconnect_mid_stream_leaves_channel_reusable`: a client of
  the real `ClientHandler` reads the response + one chunk then aborts —
  asserts no voucher/accounting is committed (nonce and bytes stay
  zero) and the same channel is immediately reusable by an honest pull
  (the serial accept loop recovers, no poisoned lock).
- `upstream_hash_mismatch_is_rejected`: a protocol-correct but
  dishonest upstream (valid signed response, paid+ack'd voucher, clean
  `StreamEnd`) serving bytes that hash wrong — asserts the requester's
  whole-blob integrity check rejects it, guarding content-addressing
  across a paid hop.

Promote the reusable raw framed-message primitives (`read_client_msg`,
`write_client_msg`, `accept_one`) into `tests/support` so the other
`cdn/client/v1` binaries can share them; only the test-specific
`lying_upstream` fake stays local.

No production code changed. `cargo nextest run -p decdn-node`: 510/510.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 6, 2026 13:14

@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 adds integration tests for several "sad path" scenarios in node-to-node pull-through delivery (addressing #746). Specifically, it introduces tests for upstream channel open failures, mid-stream client disconnections, and upstream hash mismatches. It also adds helper functions (read_client_msg, write_client_msg, and accept_one) to the test support module to facilitate raw framed-message interactions. 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.

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 expands the cdn/client/v1 node-to-node paid pull-through integration coverage by adding three sad-path scenarios requested in #746. It keeps scope strictly in tests, promoting a few reusable framed-message helpers into crates/node/tests/support and adding failure-mode assertions around stream_fetch and ClientHandler behavior.

Changes:

  • Add reusable raw framed-message helpers (read_client_msg, write_client_msg, accept_one) for cdn/client/v1 integration tests.
  • Add sad-path node-to-node integration tests covering: upstream refusing connections (fast-fail), client disconnect mid-stream (channel not advanced + reusable), and upstream hash mismatch (integrity rejection).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/node/tests/support/mod.rs Adds shared framed-message read/write helpers and a one-shot accept helper for raw integration-test servers/clients.
crates/node/tests/node_to_node_pull_through.rs Adds three sad-path node-to-node integration tests and a small “lying upstream” fake server to drive integrity-check behavior.

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

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

Coverage report

Total: 87.40% (was 87.40%, ● 0.00%) — 29678/33955 lines

No coverage data for changed Rust files.

History
Commit Total Δ vs base
e36f0d1 (HEAD) 87.40% ● 0.00%

@thiras
thiras merged commit f1d0574 into main Jun 6, 2026
20 checks passed
@thiras
thiras deleted the test/node-to-node-pull-through-sad-paths-746 branch June 6, 2026 13:19
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.

2 participants