Conversation
…nto the history endpoint module/ownership_chain/pagination.rs was never declared as a module, so paginate() and Page were not compiled into the service at all, and nothing called them: GET /transfer/:document_hash returned the whole chain however long it was. * declare the module; * harden paginate() while switching it on: a cursor past the end of the chain now yields an empty page instead of panicking on items[cursor..end], and a page_size of 0 is treated as 1 so a page always makes progress; * add seven unit tests for it (first/middle/exact-fit/last page, cursor at and past the end, zero page size, empty input) - the file had none; * wire cursor/page_size query parameters into the live handler with a ChainHistoryPage response (items, next_cursor, total), DEFAULT_CHAIN_PAGE_SIZE 20 capped at MAX_CHAIN_PAGE_SIZE 200; * add five integration tests against the real router. Calling /transfer/:hash with neither parameter still returns the bare array, so existing clients are unaffected; passing either opts into the paged envelope.
…run any test) Three independent breakages on main, unrelated to CodeGirlsInc#1346 but blocking it: * Cargo.toml pinned chrono without its serde feature, so Event's DateTime<Utc> fields had no Serialize/Deserialize impl (5 errors in event.rs); * AppState derives Clone and holds a governor RateLimiter, which is not Clone (E0277 at lib.rs:78) - the limiter is now Arc-wrapped behind the existing DefaultRateLimiter alias, so every build_rate_limiter(...) call site is unchanged; * src/stellar.rs's mock test moves data_key into the json! closure and then asserts on it (E0382). None of these are new; without them cargo test cannot even build the lib target, for any toolchain that can parse the lock.
…endpoint The live router never mounts GET /transfer/:document_hash, so paginating that handler changed nothing reachable. Move the paging onto /verify/:hash/history, which the router does mount and which returns the same chain. - cursor/page_size are opt-in: without params the response is byte-identical to before (full chain, next_cursor: null), so no existing consumer breaks. - next_cursor is added to HistoryResponse; count stays the chain total. - ChainHistoryPage dropped (dead while the transfer handler was reverted). - Cargo.toml: tower gains the util feature - the test target imports tower::util::ServiceExt, and without it no integration test could compile. - Integration tests now drive the mounted endpoint: full chain, first page, last page, cursor past the end (200 + empty, not 500), page_size cap.
|
@jarik2014 is attempting to deploy a commit to the Mftee's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Baseline comparison, as promised — this is the "not mine" arm. Unbreak commit alone, with the pagination wiring reverted ( This branch: The seven extra tests are the new |
Closes #1346.
The gap
contract/src/module/ownership_chain/pagination.rsexisted with a workingpaginate()but was never reachable:mod.rsdid not declare the module, so nothing compiled it, and no handler called it. That is the whole issue — not a missing algorithm, a missing wire.What this does
paginationmodule insrc/module/ownership_chain/mod.rs.cursor/page_sizeto the endpoint that actually serves the chain:GET /verify/:hash/history, which the router insrc/lib.rsmounts and which already returns the ownership-chain records.next_cursor: null). Passpage_sizeand/orcursorand you get a page plusnext_cursor;countstays the total length of the chain.next_cursortoHistoryResponse(additive field).paginate()(first/last page, exact fit, cursor at and past the end, zero page size, empty input) and 5 integration tests on the mounted endpoint (full chain without params, first page reports the cursor, last page has none, cursor past the end is a 200 with an empty page rather than a 500, andpage_sizeis capped).One thing worth knowing
get_transfer_historyinsrc/lib.rsis not mounted by the live router —routes.rsdeclaresGET /transfer/:document_hash, but the app the tests build (app()inlib.rs) never adds it, so that handler is unreachable and paginating it would have changed nothing. I first wired the pagination there, found the route missing, and moved it to/verify/:hash/history. Both handlers exist; only one is served. If you want the/transfer/:document_hashroute mounted as well, say so and I will add it in a separate change.Pre-existing breakage this branch has to carry
contract/does not compile onmainat all, so no test could run:The first commit fixes exactly those (chrono
serdefeature, the rate limiter behind anArc, the moveddata_keyin the mock), plus one more that only shows up once the tests compile: the integration test target importstower::util::ServiceExt, which needstower'sutilfeature enabled inCargo.toml. Split it out if you prefer to land the unbreak on its own — it is one commit and nothing in it is specific to pagination.Verification (stable toolchain;
contract/rust-toolchain.tomlpins 1.82, which cannot even parse a lockfile dependency requiring edition2024)The 11 remaining failures are pre-existing harness problems in code this change does not touch —
hash_validator::tests::sha256/sha512_rejects_non_ascii_unicode_and_binary_characters, sixstellar::tests::*(mock keypanics withInvalid secret key: InvalidStrKeyChecksum, Horizon 404/500 mocks), and twowebhook::tests::*. They cannot be compared againstmaindirectly becausemaindoes not compile; the comparison is against the unbreak commit alone, which I will paste here when that run finishes.