Repository navigation
test(node): node-to-node pull-through sad-path coverage (#746) - #827
Conversation
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]>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) forcdn/client/v1integration 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.
Coverage reportTotal: 87.40% (was 87.40%, ● 0.00%) — 29678/33955 lines No coverage data for changed Rust files. History
|
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/v1node-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.upstream_channel_open_failure_pull_fails_cleanlystream_fetchreturns a cleanErrthat fails fast (not a hang to the deadline); the fake upstream is joined so its panics surfaceclient_disconnect_mid_stream_leaves_channel_reusableClientHandlerreads the response + one chunk, then aborts before payingupstream_hash_mismatch_is_rejectedStreamEnd) serving bytes that hash to the wrong valueThe reusable raw framed-message primitives (
read_client_msg,write_client_msg,accept_one) are promoted intotests/supportso the othercdn/client/v1binaries can share them; only the test-specificlying_upstreamfake 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 callopen_or_reuse_channelis 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 originalis_err()-only assertion plus a barerefuser.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: cleancargo clippy -p decdn-node --tests: no warnings (anti-panic policy satisfied)cargo nextest run -p decdn-node: 510/510 pass🤖 Generated with Claude Code