Skip to content

test(node): pin that the shutdown redeem sweep applies the configured floor - #2260

Merged
alpergundogdu merged 2 commits into
mainfrom
fix/2235-shutdown-sweep-floor-test
Oct 1, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
fix/2235-shutdown-sweep-floor-test

Conversation

@yigitdot

@yigitdot yigitdot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds four service-level tests for PoolSettlementService::shutdown, built against a mocked PaymentPool provider with one seeded lane:
    • shutdown_sweep_leaves_a_sub_floor_lane_unread: a lane below blockchain.redeem_threshold_micro_usdc is planned (decdn_unredeemed_usdc set) but left alone — no getWatermarks read, so no redeemMany;
    • shutdown_sweep_reconciles_a_lane_at_the_floor: a lane exactly at the floor reaches the pre-submit reconcile; the chain reports it settled, so nothing is sent;
    • shutdown_sweep_submits_redeem_many_for_an_unsettled_lane: an unsettled lane at the floor reaches redeemMany (an explicit queued RPC failure counts one refused send and one redemption failure);
    • shutdown_sweep_redeems_despite_a_failed_flush: with a lane store whose flush always fails, the shutdown sweep still sends redeemMany.
  • The first test fails if final_redeem_sweep passes a U256::ZERO floor, which the existing zero-floor mechanics tests cannot catch. The fourth fails if it passes strict_flush: true, the literal on the same call.
  • Test-only; the service is built with a struct literal inside the module, so no bootstrap seam is added.

Test plan

  • cargo nextest run -p decdn-node payment_settlement (69 passed; the four new tests stable over 5 repeat runs)
  • Mutation checks: U256::ZERO floor fails only the sub-floor test; strict_flush: true fails only the failed-flush test
  • cargo clippy --workspace --all-targets -- -D warnings, cargo fmt -- --check, RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items

Closes #2235

🤖 Generated with Claude Code

… floor

Build PoolSettlementService with a struct literal in mod tests and drive
shutdown against a mocked PaymentPool with one seeded lane. A sub-floor
lane issues no getWatermarks read; a lane at the floor reaches the
pre-submit reconcile, and an unsettled one reaches redeemMany. The first
test fails if final_redeem_sweep passes a zero floor.

Closes #2235

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 02:21

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 38dc570 in the fix/2235-shutdown-sw... branch remains at 87%, unchanged from commit ef4bb89 in the main branch.

Show a line coverage summary of the most impacted files.
File main ef4bb89 fix/2235-shutdown-sw... 38dc570 +/-
crates/incentiv...eth_identity.rs 99% 98% -1%
crates/client/src/lib.rs 92% 92% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/protocol/src/framing.rs 97% 97% 0%
crates/client/src/streamer.rs 91% 92% +1%
crates/node/src/metrics.rs 96% 97% +1%
crates/node/src...t_settlement.rs 74% 83% +9%

Updated October 01, 2026 04:46 UTC

Add a FailingFlushStore and a test that fails if final_redeem_sweep
passes strict_flush true. Rename the at-floor reconcile test to match
what it checks, assert the send and failure counters directly, queue an
explicit send failure, and tighten the test doc comments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alpergundogdu

Copy link
Copy Markdown
Contributor

Review: approve with nits

The tests pin the floor. final_redeem_sweep passes self.redeem_threshold down to redeem_planned_lanes, which returns before the getWatermarks read when the total is under the floor. With a zero floor, shutdown_sweep_leaves_a_sub_floor_lane_unread fails twice over: the queued response is consumed and redemption_failures_total goes to 1. Flake risk is low: no sleeps, no ports, mocked Asserter, per-test Metrics, registered_until = u64::MAX. CI is green.

Nits

  • shutdown_sweep_reconciles_a_lane_at_the_floor (~:3393) overlaps with the test at :3419, which already drives a lane exactly at the floor through the reconcile, and with a_set_that_clears_the_floor_in_total_reads_every_lane (:3216). Drop it, or keep it as the explicit boundary case.
  • The tests at :3419 and :3449 differ only in the store. They could merge into one test with a failing flush that also asserts reconcile_ok_total 1, though two tests give clearer failure messages.
  • :3415 "submits redeem_many": the queued failure is probably consumed by a filler RPC rather than eth_sendTransaction, so the test proves the send was attempted, not its calldata. The doc comment is accurate as written; no change needed.

@alpergundogdu

Copy link
Copy Markdown
Contributor

Decision on the review nits

Keep the tests as they are: the at-floor test documents the boundary, and separate tests give clearer failures. Good to merge.

@alpergundogdu
alpergundogdu merged commit f6de71c into main Oct 1, 2026
30 checks passed
@alpergundogdu
alpergundogdu deleted the fix/2235-shutdown-sweep-floor-test branch October 1, 2026 13:37
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.

node: service-level test that the shutdown redeem sweep applies the configured floor

3 participants