Skip to content

Latest commit

 

History

History
39 lines (23 loc) · 2.4 KB

File metadata and controls

39 lines (23 loc) · 2.4 KB

Closes #1516

Description

Lock in the pagination boundary offset=0, offset==count, limit==MAX_QUERY_LIMIT with explicit unit tests on the pagination module. These three edge cases meet at a single critical point — when the collection size, the requested limit, and the hard cap all equal MAX_QUERY_LIMIT (100) — and were previously covered only incidentally by broader proptests.

Also wires the existing pagination module and its test_queries companion into the crate module tree so they are compiled and exercised by cargo test.

Changes Made

Files Modified

  • quicklendx-contracts/src/lib.rs — added mod pagination; + #[cfg(test)] mod test_queries; declarations; changed pagination from pub to private
  • quicklendx-contracts/src/pagination.rs — removed extern crate alloc; and pub const MAX_QUERY_LIMIT (now imports crate::MAX_QUERY_LIMIT)
  • quicklendx-contracts/src/test_queries.rs — added 4 new test functions; updated import to use crate::MAX_QUERY_LIMIT

Key Changes

  1. Wired pagination.rs into the crate (mod pagination; at lib.rs:89) — the module was already present on disk but never declared. Made private to avoid exporting a duplicate MAX_QUERY_LIMIT constant that could confuse Soroban's #[contractimpl] spec-generation macro.

  2. Wired test_queries.rs as a test module (#[cfg(test)] mod test_queries; at lib.rs:164) — the existing pagination unit tests and escrow query consistency tests are now compiled and run under cargo test.

  3. Removed extern crate alloc; from pagination.rs — the crate root (lib.rs:33) already declares it.

  4. Removed duplicate pub const MAX_QUERY_LIMIT from pagination.rslib.rs:295 and investment_queries.rs:52 each already define it. The third copy (from the newly-wired module) created ambiguity in Soroban's contract-interface macro, causing 19 compilation errors. Now pagination.rs uses crate::MAX_QUERY_LIMIT via a use import.

  5. Added 4 targeted tests (test_queries.rs section 10) covering the boundary at MAX_QUERY_LIMIT:

    • test_offset_zero_limit_max_on_full_collection_has_no_more
    • test_offset_zero_limit_max_on_full_collection_returns_all
    • test_offset_equals_count_limit_max_returns_empty
    • test_cross_consistency_at_max_query_limit_boundary

Testing

Run from quicklendx-contracts/: cargo test -- test_queries

Related Issues

Closes #1516