Skip to content

Test/insurance batch pay partial results#795

Merged
Baskarayelu merged 2 commits into
Remitwise-Org:mainfrom
happyboy24:test/insurance-batch-pay-partial-results
Jun 19, 2026
Merged

Test/insurance batch pay partial results#795
Baskarayelu merged 2 commits into
Remitwise-Org:mainfrom
happyboy24:test/insurance-batch-pay-partial-results

Conversation

@happyboy24

Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive coverage and documentation for Insurance::batch_pay_premiums partial-result behavior and payment accounting.

This PR pins and documents deterministic batch semantics for mixed policy batches and ensures payment state transitions remain scoped only to successfully processed policies.

Changes

Tests

  • Added coverage for mixed batches containing:

    • valid policies
    • inactive policies (PolicyInactive)
    • nonexistent policies (PolicyNotFound)
    • policies owned by another account
  • Added assertions for documented batch processing behavior and returned u32 semantics.

  • Added verification that next_payment_date advances only for successfully paid policies.

  • Added owner-scoping tests to ensure callers cannot pay premiums for policies they do not own.

  • Added duplicate policy ID coverage to verify deterministic handling (duplicates counted once).

  • Added empty batch coverage to ensure:

    • returns 0
    • produces no state changes
  • Added all-invalid batch coverage (returns 0).

  • Added coverage for already-paid-this-period scenarios.

  • Exercised behavior under larger batch inputs to validate consistency at scale.

Documentation

  • Documented batch_pay_premiums behavior in docs/.
  • Added inline test comments explaining partial-result expectations and reconciliation implications.

Documented Batch Semantics

batch_pay_premiums follows skip-and-continue processing.

For each policy ID:

  • eligible policies are paid successfully;
  • inactive, missing, unauthorized, or otherwise ineligible policies are skipped;
  • processing continues for remaining IDs.

Return value:

  • u32 = number of unique policies successfully paid.

State updates:

  • next_payment_date advances only for successfully paid policies.
  • skipped policies remain unchanged.

Validation

Executed:

cargo test -p insurance batch_pay_premiums -- --nocapture
cargo test -p insurance
cargo clippy

All tests passing with no panics on failure paths and aligned with typed InsuranceError handling.

closes #763

@Baskarayelu

Copy link
Copy Markdown
Contributor

deterministic partial-result accounting for batch_pay_premiums - that path needed the atomicity guarantee. merging 👍

@Baskarayelu Baskarayelu merged commit 0272531 into Remitwise-Org:main Jun 19, 2026
4 of 12 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.

Insurance: add batch_pay_premiums deterministic partial-result accounting and atomicity tests

2 participants