chore(test): bitswap limit tests - #7443
Conversation
WalkthroughThe request manager exposes inbound serving limits within the Bitswap crate. New tests validate wantlist size limits, concurrency saturation, permit retention, and empty wantlists. Manifest tests now use a shared random CID helper. ChangesBitswap serving limits
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/libp2p_bitswap/tests/request_manager.rs (1)
123-144: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winMake the saturation test independent of the Tokio runtime blocking-thread limit by using a small test-local capacity.
The test depends on each of the first
capspawn_blockingtasks executing and blocking inGatedStore::contains()while holding permits. IfFOREST_MAX_CONCURRENT_INBOUND_WANTLIST_SERVESis set above the runtime's blocking-thread limit (default 512), excess tasks remain queued and cannot signalentered_rx. The loop at line 139 then times out. Use a test-local constant for the cap (e.g., 4) instead of reading the global variable, or explicitly configure the test runtime to guarantee sufficient blocking capacity:#[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn serve_drops_when_concurrency_saturated() { let cap = 4; // test-local, independent of global config // ... rest of testThis ensures the test remains deterministic regardless of how the global cap is set.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/libp2p_bitswap/tests/request_manager.rs` around lines 123 - 144, Update the saturation test around serve_drops_when_concurrency_saturated to use a small test-local capacity, such as 4, instead of dereferencing MAX_CONCURRENT_INBOUND_WANTLIST_SERVES. Keep the existing saturation and entered_rx synchronization logic unchanged so the test remains deterministic regardless of the configured global limit.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/libp2p_bitswap/tests/request_manager.rs`:
- Around line 123-144: Update the saturation test around
serve_drops_when_concurrency_saturated to use a small test-local capacity, such
as 4, instead of dereferencing MAX_CONCURRENT_INBOUND_WANTLIST_SERVES. Keep the
existing saturation and entered_rx synchronization logic unchanged so the test
remains deterministic regardless of the configured global limit.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b3c7a370-5b42-42c7-b6fd-addd11073473
📒 Files selected for processing (4)
src/libp2p_bitswap/request_manager.rssrc/libp2p_bitswap/tests/request_manager.rssrc/shim/machine/manifest.rssrc/utils/rand/mod.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
filecoin-project/lotus(manual)
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
Bug Fixes
Tests