Skip to content

test(insurance): cover reinsurance agreements and recovery path - #1073

Open
Moonwalker-rgb wants to merge 1 commit into
MettaChain:mainfrom
Moonwalker-rgb:fix/1026-insurance-reinsurance-tests
Open

test(insurance): cover reinsurance agreements and recovery path#1073
Moonwalker-rgb wants to merge 1 commit into
MettaChain:mainfrom
Moonwalker-rgb:fix/1026-insurance-reinsurance-tests

Conversation

@Moonwalker-rgb

@Moonwalker-rgb Moonwalker-rgb commented Aug 27, 2026

Copy link
Copy Markdown

Closes #1026

Summary

The reinsurance money path in contracts/insurance had no test coverage: agreement registration, threshold crossing, recovery success/failure, and pool behavior when recovery fails were all unpinned.

Changes

New tests in contracts/insurance/src/tests.rs cover:

  • Payout below the pool's reinsurance threshold: no recovery is attempted or recorded, even when a covering agreement exists.
  • Payout exactly at the threshold: no recovery (the condition is strictly amount > threshold).
  • Payout above the threshold: recovery is recorded on the agreement, in the recovery ledger, and in the reinsurance stats.
  • Recovery failure (no agreement registered): payout proceeds from pool capital.
  • Recovery failure (only agreement is inactive): payout proceeds from pool capital.
  • Recovery failure with insufficient pool capital: the claim is rejected (InsufficientPoolFunds) instead of paying out uncovered funds.

Registration auth is pinned by the existing test_register_reinsurance_works and test_register_reinsurance_unauthorized_fails.

Verification

  • cargo test -p propchain-insurance passes (121 tests).

Pin the reinsurance money path: agreement registration auth, payouts
below and exactly at the threshold (no recovery), payouts above the
threshold (recovery recorded), and pool behavior when recovery fails
(payout from pool capital, or claim rejection when capital is
insufficient). Fixes MettaChain#1026.
@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Moonwalker-rgb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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 reinsurance path has no tests: agreements and recovery are uncovered

1 participant