Repository navigation
test(node): integration tests for DHT FindValue lookup (closes #711) - #719
Conversation
Adds `crates/node/tests/dht_integration.rs` covering the iterative FindValue lookup path from PR #673, the behaviours that only manifest once the routing table and negative cache interact with a live lookup: - bucket-overflow LRU eviction + node departure (`remove`) — the routing table is LRU-on-overflow, not split-on-overflow Kademlia, so issue #711's "k-bucket split" maps onto eviction behaviour; - convergence after a peer departs the routing table; - an unreachable peer mid-lookup (handler dropped) does not wedge the pass — pinned with the dead peer as the *closest* candidate so the live, farther provider still surfacing is non-trivial, plus a wall-clock guard against a hang regression; - genuine two-round convergence via a `closer_nodes` referral, the first end-to-end coverage of the iterative `observed_closer` loop; - negative-cache TTL expiry un-suppresses a provider on the same cache instance, proving a stale entry does not poison future lookups. Promotes `NegativeProbeCache::with_capacity_and_ttl` to a documented `pub` test/tuning seam: the cache is `Instant`-anchored, so `tokio::time` cannot drive it and a short injected TTL is the only deterministic way to exercise expiry from an integration test. Production still uses `new()` with the ADR 001 defaults. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Coverage reportTotal: 89.27% (was 89.25%, ▲ +0.02%) — 21608/24204 lines
History
|
There was a problem hiding this comment.
Pull request overview
Adds integration test coverage for the iterative FindValue DHT lookup path (PR #673), exercising routing-table LRU eviction + node departure, multi-round convergence via closer_nodes, tolerance of unreachable peers, and negative-cache TTL expiry. To enable deterministic short-TTL expiry tests (the cache is Instant-anchored, so tokio::time cannot drive it), NegativeProbeCache::with_capacity_and_ttl is promoted to a documented pub test/tuning seam.
Changes:
- New
crates/node/tests/dht_integration.rswith 5 integration tests covering bucket overflow + departure, convergence after departure, unreachable closest peer, two-round closer_nodes referral, and negative-cache TTL expiry. - Promote
NegativeProbeCache::with_capacity_and_ttlfrom private topubwith documentation as a test/tuning seam.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/node/tests/dht_integration.rs | New integration tests covering multi-round, unreachable, departure, and TTL-expiry behaviors of find_providers. |
| crates/node/src/dht/negative_cache.rs | Make with_capacity_and_ttl public with rationale doc so integration tests can inject short TTLs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Closes #711 — adds integration coverage for the iterative
FindValuelookup path introduced in PR #673 (ADR 022 §FIND_VALUE Flow, §Routing Table, §Lookup integrity). New filecrates/node/tests/dht_integration.rsplus one production test seam.The issue's auto-triage framing assumed Kademlia mechanics this codebase doesn't have; the tests were written against the actual behaviour, and the module doc is explicit about each adaptation:
find_providersnever mutates the routing table or marks peers stale on failure; there is no stale-pruning mechanism to test.Instant-anchored, sotokio::time::pause/advance(which the issue suggested) has no effect — hence the injected short-TTL seam.Tests added
bucket_overflow_evicts_lru_and_departed_node_is_removedK_BUCKET_SIZE→ LRU eviction;remove()of a surviving entry on node departurefind_providers_converges_after_peer_departsfind_providers_tolerates_unreachable_peerfind_providers_converges_via_closer_nodes_second_roundcloser_nodesreferral — first E2E coverage of the iterativeobserved_closerloopfind_providers_negative_cache_expires_after_ttlProduction change
NegativeProbeCache::with_capacity_and_ttlpromoted from private to a documentedpubtest/tuning seam (production still usesnew()with the ADR 001 1024-entry / 5-minute defaults). Required because the cache isInstant-anchored and#[cfg(test)]constructors aren't visible to thetests/crate.Review
Ran a multi-agent PR review (code / tests / comments) before opening; acted on all critical and important findings — strengthened the unreachable-peer test from a partly-vacuous assertion, added the missing multi-round E2E test, and corrected two doc inaccuracies.
Verification
cargo fmt --check,cargo clippy -p decdn-node --tests— cleancargo nextest run -p decdn-node --test dht_integration— 5/5 pass, stable across repeated runsdht_lookup,dht_loopback,dht_bootstrap,negative_cacheunit tests) — unaffected, all pass🤖 Generated with Claude Code