Skip to content

test(insurance,reporting): coverage_to_premium ratio guard + report t… (#736)#745

Merged
Baskarayelu merged 1 commit into
Remitwise-Org:mainfrom
primexk5:test/insurance-ratio-guard
Jun 18, 2026
Merged

test(insurance,reporting): coverage_to_premium ratio guard + report t… (#736)#745
Baskarayelu merged 1 commit into
Remitwise-Org:mainfrom
primexk5:test/insurance-ratio-guard

Conversation

@primexk5

Copy link
Copy Markdown
Contributor

Description

This PR introduces boundary tests for the coverage_to_premium ratio logic to ensure that nonsensical policies are blocked on creation and that the ratio is accurately reported downstream.

Fixes #736

Changes Included

  • Insurance Crate Tests (insurance/tests/ratio_guard.rs):
    • Asserts the on-create ratio boundary: accepts coverage_amount == premium * 12 * 500 but strictly rejects +1 with an UnsupportedCombination error.
    • Verifies the guard correctly interacts with per-CoverageType minimum and maximum bounds (ensuring failures correctly isolate ratio violations vs. type bound violations).
  • Reporting Crate Tests (reporting/tests/insurance_report_ratio.rs):
    • Asserts that get_insurance_report.coverage_to_premium_ratio is correctly computed using checked math to prevent division-by-zero errors.
    • Verifies that annual_premium correctly aggregates as monthly_premium * 12.
    • Ensures that deactivated policies are fully excluded from the reporting aggregates and that zero active policies are handled gracefully.

Context & Notes

  • Built using Soroban SDK 21.7.7 in a #![no_std] environment.
  • Validated via cargo test -p insurance and cargo test -p reporting.

…ests (Remitwise-Org#736)

Pins the on-create ratio boundary and the downstream
coverage_to_premium_ratio computation in get_insurance_report.
@Baskarayelu

Copy link
Copy Markdown
Contributor

good call covering the weakest-tested crate - the coverage_to_premium ratio guard plus the report-side assertion close a real gap on insurance. merging 👍

@Baskarayelu Baskarayelu merged commit e054186 into Remitwise-Org:main Jun 18, 2026
2 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.

Insurance: add coverage_to_premium ratio guard tests feeding reporting's get_insurance_report

2 participants