Skip to content

test(node): two-hop node-to-node paid pull-through integration test (#746) - #813

Merged
thiras merged 2 commits into
mainfrom
test/746-node-to-node-pull-through
Jun 4, 2026
Merged

thiras merged 2 commits into
mainfrom
test/746-node-to-node-pull-through

Conversation

@thiras

@thiras thiras commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the first multi-hop integration test for the cdn/client/v1 paid pull-through path (#746). It composes the existing protocol halves — ClientHandler (server) and stream_fetch (requester), both shipped in #733 — into a real two-hop chain over in-process iroh endpoints on localhost, off-chain vouchers only (no anvil):

  • Hop 1 (A → B): mid-node B paid-pulls a 1.5 MiB blob from upstream node A; asserts bytes match and the A↔B channel advances (nonce 2 / full byte count / exact amount).
  • Step 2: B's cache is built from the pulled bytes — an explicit stand-in for the deferred NodeOrigin / cache-miss→upstream-channel runtime wiring (CacheEngine has no public ingest API; only origin pull-through).
  • Hop 2 (B → client): a leaf client paid-pulls from B; asserts bytes survive both hops intact end-to-end and the B↔client channel advances.

Distinct per-hop rates (10 vs 13) with exact rate-derived amount checks, exactly-one-channel-per-store, and a cross-hop isolation re-check prove pricing is per-server with no cross-talk between B's buyer and seller roles (sharing one endpoint). The existing single-hop loopback suite (client_loopback.rs) only covered client → one node.

Scope / boundary

This closes the in-scope portion of #746. The full automatic flow #746 describes — a node auto-opening an upstream channel on cache miss and streaming through — does not exist in the runtime yet: there is no NodeOrigin, and the cache-engine hook that would call open_or_reuse_channel is deferred on provider discovery (ADR 001/022; the bootstrapped BuyerChannelService is intentionally bound to _buyer_channel_service). That orchestration is follow-up work alongside the DHT effort and is not asserted here. No production code changed.

Verification

  • cargo fmt -- --check: clean
  • cargo clippy -p decdn-node --tests: no warnings (anti-panic policy satisfied)
  • New test: passes, deterministic across repeated runs
  • cargo nextest run -p decdn-node: 450/450 pass

🤖 Generated with Claude Code

…746)

Adds the first multi-hop integration test for the cdn/client/v1 paid
pull-through path, composing the existing ClientHandler (server) and
stream_fetch (requester) halves into a real two-hop chain over in-process
iroh endpoints on localhost, off-chain vouchers only (no anvil):

- Hop 1 (A -> B): mid-node B paid-pulls a 1.5 MiB blob from upstream node
  A; asserts bytes match and the A<->B channel advances.
- Step 2: B's cache is built from the pulled bytes (explicit stand-in for
  the deferred NodeOrigin / cache-miss->upstream-channel runtime wiring,
  which depends on provider discovery, ADR 001/022).
- Hop 2 (B -> client): a leaf client paid-pulls from B; asserts bytes
  survive both hops intact end-to-end and the B<->client channel advances.

Distinct per-hop rates (10 vs 13) with exact rate-derived amount checks,
exactly-one-channel-per-store, and a cross-hop isolation re-check prove
pricing is per-server with no cross-talk between B's buyer and seller
roles. The single-hop loopback suite only covered client -> one node.

Closes the in-scope portion of #746; the automatic runtime orchestration
remains deferred on DHT provider discovery.

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

@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 integration test, node_to_node_pull_through_two_hops, to verify a two-hop node-to-node paid pull-through flow. The test simulates an upstream node, a mid-node, and a client to ensure data integrity and proper payment channel progression across both hops. Feedback on the test suggests propagating the join results of the background server tasks rather than ignoring them, ensuring that any background panics or failures are properly caught and fail the test.

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

Adds a new multi-hop integration test covering the cdn/client/v1 paid pull-through path by composing the existing requester (stream_fetch) and server handler (ClientHandler) across two in-process iroh hops (A→B, then B→client), validating end-to-end bytes and per-hop off-chain channel accounting.

Changes:

  • Introduces a two-hop paid pull-through integration test (A→B paid pull, B→client paid serve) over real localhost iroh endpoints.
  • Asserts per-hop channel advancement (nonce/bytes/amount) with distinct rates, and verifies cross-hop isolation (B serving the client doesn’t mutate A↔B channel state).
  • Manually populates B’s cache from hop-1 bytes via the existing test helper (cache_with_blob) to stand in for not-yet-implemented runtime orchestration.

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

@github-actions

github-actions Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 87.16% (was 87.15%, ● 0.00%) — 28094/32234 lines

No coverage data for changed Rust files.

History
Commit Total Δ vs base
8c7b4b3 87.16% ● 0.00%
294c4b4 (HEAD) 87.16% ● 0.00%

Await the spawned accept-loop tasks with `?` instead of `let _ =` so a panic
in either background server task fails the test rather than being silently
swallowed. After `close()` the loops exit cleanly, so this only surfaces
genuine panics.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@thiras
thiras merged commit 101f043 into main Jun 4, 2026
19 checks passed
@thiras
thiras deleted the test/746-node-to-node-pull-through branch June 4, 2026 16:13
thiras added a commit that referenced this pull request Jun 4, 2026
…own (#814)

Await the spawned accept-loop task with `?` instead of `let _ =` across the
loopback suite so a panic in the background server task fails the test rather
than being silently swallowed. After `close()` the accept loop exits cleanly,
so this only surfaces genuine panics. Follow-up to the same fix in the
two-hop test (#813).

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.

2 participants