Repository navigation
test(cache): use full-entropy keys in tinylfu policy tests (#1854) - #1856
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the tinylfu policy tests in decdn-cache to use realistic, full-entropy cache keys so the sharded frequency estimator routing logic is actually exercised (aligning with the established convention in sketch.rs and addressing #1854).
Changes:
- Replaces the degenerate test helper
Hash::from([b; 32])withHash::new(i.to_le_bytes())to generate uniformly distributed test keys. - Updates all
tinylfu.rspolicy tests to passu32inputs to the new helper.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.08% (was 82.08%, ● 0.00%) — 68889/83925 lines
History
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1854.
crates/cache/src/policy/tinylfu.rsused degenerateHash::from([b; 32])keys in all five tests. Those keys make the shard-routing slice and the four row slices perfectly correlated, putting every row on one column — so the tests cannot observe a routing bug. The sister modulesketch.rsalready establishes the full-entropy convention (Hash::new(i.to_le_bytes())).Change
fn h(b: u8) -> Hash { Hash::from([b; 32]) }withfn h(i: u32) -> Hash { Hash::new(i.to_le_bytes()) }, matchingsketch.rs'skey().u32literals.The cache crate's
Hashisiroh_blobs::Hash, soHash::new(bytes)computes a real BLAKE3 digest of the input — full-entropy keys with realistic shard distribution.Verification
cargo nextest run -p decdn-cache— all 392 tests passcargo clippy— cleancargo fmt -- --check— cleanTest-only change; no production code, wire, or format changes.