Skip to content

Add property-based tests for RouteCacheKey canonicalization invariants #351

@coderabbitai

Description

@coderabbitai

Background

Introduced in PR #346, RouteCacheKey::for_route_request canonicalizes route request JSON payloads before hashing. The current test suite covers only eight discrete coordinate cases and single structural examples.

Problem

Unexplored input combinations remain untested:

  • Arbitrary JSON key orderings at all nesting depths
  • All permutations of theme arrays (themes, themeIds, interestThemeIds)
  • Floating-point edge cases (precision boundaries at five decimal places, NaN, Infinity, subnormal values)
  • Deeply nested objects with mixed coordinate and non-coordinate fields

Required work

Introduce proptest-based property tests in backend/src/domain/ports/cache_key.rs (or a companion file) with strategies that:

  1. Generate arbitrary serde_json::Value objects with randomized key ordering at every nesting depth and assert the derived key is identical regardless of ordering.
  2. Generate all permutations of theme array values and assert key stability.
  3. Generate f64 values across the full range and assert rounding to five decimal places is applied consistently.
  4. Assert that materially different payloads never produce the same key (collision resistance spot-check).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions