Skip to content

test(node): prove the reclaim sweep returns when a reclaim receipt never arrives - #2525

Merged
thiras merged 2 commits into
mainfrom
test/2495-reclaim-sweep-receipt-lapse
Oct 18, 2026
Merged

thiras merged 2 commits into
mainfrom
test/2495-reclaim-sweep-receipt-lapse

Conversation

@thiras

@thiras thiras commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

reclaim_once bounds its reclaim receipt wait with RECEIPT_TIMEOUT (#2492). The only test of that arm, an_unreadable_sweep_reclaim_receipt_logs_the_tx, runs on alloy's Asserter, whose empty queue fails the receipt read at once, so it passes with or without the bound.

  • a_sweep_reclaim_that_never_mines_lapses_and_keeps_the_row (crates/node/src/buyer_pool/tests.rs) runs sweep_reclaimable_once on ScriptedRpc::parked_receipt() under a paused clock. The reclaim sends and its receipt never arrives. The sweep returns at RECEIPT_TIMEOUT, warns reclaim receipt not read with the tx hash, meters decdn_buyer_reclaim_failures_total to 1, and keeps the row.
  • ScriptedRpc::at_head(timestamp) (crates/incentive/src/test_rpc.rs, test-util) answers eth_getBlockByNumber with a head block at that timestamp. The sweep reads the chain head for its grace-window pre-check before it sends, and ScriptedRpc left that read pending, which parked the sweep before the receipt wait.
  • crates/incentive/src/test_rpc/tests.rs pins that builder: a scripted head decodes through the provider at its timestamp, and a block read with no head set parks. The sweep is optimistic on a head-read failure, so without this a block shape that stops decoding would leave the node test on the fallback path with its head gate uncovered and no failure.

Closes #2495

Reviewer notes

  • Read the new test first, then the at_head arm in test_rpc.rs. The head block is Block::<Transaction>::default() with the timestamp set, the same shape the CLI pool tests already feed an Asserter.
  • The existing Asserter test stays: it covers the receipt read that errors, the new one covers the read that never answers. Its doc comment now says so.
  • No CHANGELOG entry: the harness change is test-util only. decdn-incentive is not in the public-api snapshot.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p decdn-node -E 'test(reclaim)' (5 passed), cargo nextest run -p decdn-incentive (320 passed) and the no_inline_test_modules guard
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items
  • contracts/ changed: n/a
  • User-visible change: n/a
  • Design change: n/a
  • PR title uses an allowed type and a lowercase subject

Mutation checks, by hand:

Mutation Result
await_receipt(pending, None) in reclaim_once the new test fails: the sweep must return when the receipt wait lapses: Elapsed(())
.at_head(0) (head before the deadline) the new test fails at once on the wait assertion, so the scripted head block decodes and gates the send

🤖 Generated with Claude Code

…ver arrives (#2495)

`a_sweep_reclaim_that_never_mines_lapses_and_keeps_the_row` runs
`sweep_reclaimable_once` on a `ScriptedRpc` whose `reclaim` receipt read
never answers, under a paused clock. The sweep returns at
`RECEIPT_TIMEOUT`, warns with the tx hash, meters
`decdn_buyer_reclaim_failures_total`, and keeps the row. With the bound
removed the test fails through its outer timeout.

`ScriptedRpc::at_head` answers `eth_getBlockByNumber` with a head block at
a chosen timestamp, which the sweep reads before it sends; without it the
head read parks the sweep before the receipt wait.

Closes #2495

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 18, 2026 15:06

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.

🟢 Approval recommended

The focused regression test covers the timeout’s required outcomes, and the test harness preserves existing defaults.

No open issues 🎉

What changed in this PR

Adds regression coverage for the reclaim receipt timeout introduced in #2492, addressing #2495 without changing production behavior.

Changes:

  • Adds a paused-clock test verifying timeout completion, warning output, failure counting, and row retention.
  • Extends ScriptedRpc with an optional chain-head timestamp response.
File Description
crates/​node/​src/​buyer_pool/​tests.rs Tests a never-arriving reclaim receipt and clarifies existing error-path coverage.
crates/​incentive/​src/​test_rpc.rs Adds scripted head-block responses for the sweep’s pre-check.

Review effort: Balanced

@github-code-quality

github-code-quality Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main 1c425e4 test/2495-reclaim-sw... 0c31df3 +/-
76% 76% 0%
View coverage of the 5 most impacted files.
File main 1c425e4 test/2495-reclaim-sw... 0c31df3 +/-
crates/node/src/dht/publish.rs 80% 78% -2%
crates/node/src...s/client/mod.rs 91% 91% 0%
crates/cache/src/engine.rs 91% 91% 0%
crates/incentiv...src/test_rpc.rs 97% 97% 0%
crates/node/src/buyer_pool.rs 80% 81% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 18, 2026 15:43 UTC

`a_scripted_head_decodes_at_its_timestamp` reads the head through the
provider on a `ScriptedRpc::at_head` transport. The sweep is optimistic
on a head-read failure, so a block shape that stops decoding would leave
the node test on that fallback path and its head gate uncovered without
a failure. `a_block_read_with_no_head_set_parks` pins the default.

The sweep lapse test also asserts the lapse reason, and the `ScriptedRpc`
doc names which block the head arm answers and what parks without one.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@thiras
thiras merged commit 6a9fbf5 into main Oct 18, 2026
31 checks passed
@thiras
thiras deleted the test/2495-reclaim-sweep-receipt-lapse branch October 18, 2026 15:44
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.

test(node): prove the reclaim sweep returns when a reclaim receipt never arrives

2 participants