Skip to content

refactor(reporting): extract paginate_dependency helper and fix tests…#742

Merged
Baskarayelu merged 2 commits into
Remitwise-Org:mainfrom
OG-wura:_featrefactor_cross_contract_dependency_clients
Jun 18, 2026
Merged

refactor(reporting): extract paginate_dependency helper and fix tests…#742
Baskarayelu merged 2 commits into
Remitwise-Org:mainfrom
OG-wura:_featrefactor_cross_contract_dependency_clients

Conversation

@OG-wura

@OG-wura OG-wura commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

close #738

PR Description

Summary

Extracts the duplicated pagination logic shared by 4 reporting reports into a
single generic paginate_dependency helper. Also fixes 55 pre-existing
compilation errors in tests.rs that blocked running any tests.

Changes

Refactor — reporting/src/lib.rs

  • New types: PaginatedResult<T> (items + data_availability)
  • New generic fn: paginate_dependency(env, fetch_page) — bounded loop
    (MAX_DEP_PAGES cap), drains pages until next_cursor == 0
  • Refactored 4 reports to use the helper:
    • get_bill_compliance_report_internal
    • get_insurance_report_internal
    • get_top_bills_report_internal
    • get_top_savings_report_internal
  • Note: get_savings_report_internal unchanged — it uses a single
    non-paginated get_all_goals call

New tests — reporting/src/paginate_dependency_tests.rs

12 unit tests covering:

  • DataAvailability::Missing (first page empty)
  • DataAvailability::Complete (cursor=0 within MAX_DEP_PAGES)
  • DataAvailability::Partial (cap reached)
  • Non-advancing cursor termination guarantee
  • Edge cases (empty middle pages, mixed empty/non-empty)

Fixed pre-existing tests.rs errors (55 total)

  • Added missing _caller arg to get_savings_report, get_bill_compliance_report,
    get_insurance_report, get_financial_health_report, get_stored_report,
    check_dependencies
  • Fixed Result unwrapping for try_ variants across the file
  • Added mock family_wallet module for check_dependencies test
  • Removed unused CoverageType import

Test results

  • 104 passed, 1 pre-existing runtime failure
    (test_verify_dependency_address_set_does_not_write_storage — storage
    accessed outside contract context, pre-dates this PR)
  • 12/12 new paginate tests: PASS

@Baskarayelu

Copy link
Copy Markdown
Contributor

clean refactor - folding the cross-contract dependency pagination into a shared paginate_dependency helper cuts a lot of duplication, and the snapshot tests still line up. merging 👍

@Baskarayelu Baskarayelu merged commit 82e58c7 into Remitwise-Org:main Jun 18, 2026
3 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reporting: refactor cross-contract dependency clients into a shared paginate_dependency helper

2 participants