Skip to content

Latest commit

 

History

History
94 lines (79 loc) · 5.84 KB

File metadata and controls

94 lines (79 loc) · 5.84 KB

Pagination Consistency Tests — Verification Output

This file captures the acceptance output for the feature/query-pagination-consistency-tests branch.

Scope

Per the Drips.network issue Add query pagination consistency tests (offset/limit, clamp MAX_QUERY_LIMIT, stable ordering), this PR adds:

  • quicklendx-contracts/src/pagination.rs — pure, self-contained pagination helpers (MAX_QUERY_LIMIT, cap_query_limit, validate_pagination_params, calculate_safe_bounds, paginate_slice).
  • quicklendx-contracts/src/test_queries.rs — 26 #[test] functions + 4 proptest! macros (each proptest runs 256 randomized cases by default).
  • quicklendx-contracts/src/test_investment_queries.rs — 12 #[test] functions + 1 proptest! macro (simulated status-filter + pagination pipeline).
  • quicklendx-contracts/src/lib.rs — minimal wiring (pub mod pagination + #[cfg(test)] mods).
  • docs/contracts/queries.md — new ## Pure Pagination Module section.

The legacy dead modules (admin.rs, bid.rs, invoice.rs, investment_queries.rs, test_limit.rs, etc.), the CI workflow, the root tests/*.rs (which contain pre-existing merge-conflict markers unrelated to this issue), and the frontend package were all left untouched.

Acceptance commands (run from quicklendx-contracts/)

cargo check --lib                                    # → finished, no warnings
cargo test --lib --verbose                           # → 46 passed; 0 failed
cargo clippy --profile test --lib -- -D warnings     # → finished, zero warnings
RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --lib # → generated, no warnings

cargo test --lib --verbose summary

running 46 tests
test test_investment_queries::prop_status_filter_then_paginate ... ok
test test_investment_queries::test_boundary_clamp_trims_effective_limit ... ok
test test_investment_queries::test_build_mock_investments_is_deterministic ... ok
test test_investment_queries::test_cross_consistency_validate_and_bounds_specific ... ok
test test_investment_queries::test_empty_dataset_always_returns_empty ... ok
test test_investment_queries::test_empty_filter_result_yields_empty_page ... ok
test test_investment_queries::test_multi_page_status_filter_reconstructs_filtered_list ... ok
test test_investment_queries::test_query_is_stable_across_repeated_calls ... ok
test test_investment_queries::test_simulated_pagination_across_sizes ... ok
test test_investment_queries::test_status_filter_then_paginate_size_three ... ok
test test_investment_queries::test_u32_max_limit_clamped_on_large_collection ... ok
test test_investment_queries::test_u32_max_limit_returns_full_small_collection ... ok
test test_investment_queries::test_u32_max_offset_always_empty ... ok
test test_queries::prop_no_panic_on_u32_extremes ... ok
test test_queries::prop_paginate_all_pages_cover_capped_prefix ... ok
test test_queries::prop_paginate_never_exceeds_cap ... ok
test test_queries::prop_paginate_preserves_order ... ok
test test_queries::test_boundary_offset_equals_total_minus_one_yields_one ... ok
test test_queries::test_boundary_offset_equals_total_yields_empty ... ok
test test_queries::test_calculate_safe_bounds_u32_max_inputs_are_safe ... ok
test test_queries::test_cap_query_limit_above_max_is_clamped ... ok
test test_queries::test_cap_query_limit_below_max_is_identity ... ok
test test_queries::test_cross_consistency_validate_vs_bounds ... ok
test test_queries::test_empty_collection_always_returns_empty ... ok
test test_queries::test_generic_paginate_on_bytes_32 ... ok
test test_queries::test_generic_paginate_on_named_id_string_newtype ... ok
test test_queries::test_generic_paginate_on_u64 ... ok
test test_queries::test_has_more_exhausting_page_is_false ... ok
test test_queries::test_has_more_over_cap_limit_clamps_correctly ... ok
test test_queries::test_has_more_past_end_is_false ... ok
test test_queries::test_has_more_within_window_is_true ... ok
test test_queries::test_no_duplicates_across_pages_various_sizes ... ok
test test_queries::test_paginate_slice_clamps_limit_101 ... ok
test test_queries::test_paginate_slice_clamps_limit_500 ... ok
test test_queries::test_paginate_slice_clamps_limit_u32_max_large_collection ... ok
test test_queries::test_paginate_slice_equals_underlying_slice ... ok
test test_queries::test_paginate_slice_is_stable_across_repeated_calls ... ok
test test_queries::test_paginate_slice_limit_u32_max_small_collection ... ok
test test_queries::test_paginate_slice_limit_zero_returns_empty ... ok
test test_queries::test_paginate_slice_offset_equals_total_returns_empty ... ok
test test_queries::test_paginate_slice_offset_past_total_returns_empty ... ok
test test_queries::test_paginate_slice_u32_max_offset_returns_empty ... ok
test test_queries::test_single_element_collection_paginates_correctly ... ok
test test_queries::test_validate_limit_zero_at_end_of_collection ... ok
test test_queries::test_validate_limit_zero_yields_zero_effective_limit ... ok
test test_queries::test_validate_params_u32_max_extremes_do_not_panic ... ok

test result: ok. 46 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.59s

Security notes

  • All arithmetic in pagination.rs uses saturating_* — no possible overflow panic.
  • Every loop is bounded by min(limit, MAX_QUERY_LIMIT, remaining).
  • paginate_slice allocation is bounded by MAX_QUERY_LIMIT * size_of::<T>().
  • No unsafe blocks; no unwrap()/expect() in non-test code.
  • The proptest properties cover the full u32 input domain for the validation helpers, confirming no-panic behaviour across any caller-supplied (offset, limit, total) triple.

Issue reference

Add tests ensuring paginated queries behave safely and consistently: limit=0 returns empty, offset beyond length returns empty, limits are clamped, and ordering is stable.

All four listed invariants are proven by explicit #[test] functions and by proptest properties.