Skip to content

Insurance pool-capital accounting is only partially tested: coverage-ratio and exposure edges are unpinned #1041

Description

@nanaf6203-bit

Insurance pool-capital accounting is only partially tested: coverage-ratio and exposure edges are unpinned

Labels / Complexity: Contract · Rust · Medium Complexity — Medium

Problem

contracts/insurance/src/lib.rs enforces pool exposure through max_coverage_ratio: create_policy and create_parametric_policy compute max_exposure = pool.available_capital.saturating_mul(pool.max_coverage_ratio) / 10_000 and reject with InsufficientPoolFunds when coverage_amount > max_exposure (lines ~818-823, ~1874-1878). The tests cover pool creation and liquidity but not the exposure boundary — a grep shows no assertion of the InsufficientPoolFunds rejection or the exactly-at-ratio case. The coverage-ratio math is the pool's solvency guard: a rounding or ratio error (e.g. * ratio / 10_000 truncation) either over-approves risk or rejects valid policies.

Why this is architecturally hard

  1. Ratio math truncation is the trap. available_capital * ratio / 10_000 truncates; tests must pin the exactly-at-ratio and one-unit-above cases so a rounding change is caught.
  2. Exposure is read at policy creation. Tests must seed a pool's capital, then create policies at/below/above the exposure limit and assert the rejection — a multi-step setup the current suite doesn't do.

Acceptance criteria

  • Tests cover: policy at exactly the coverage-ratio limit (accepted), one unit above (rejected with InsufficientPoolFunds), and the pool's capital after acceptance.
  • cargo test -p propchain-insurance passes.

Getting started

Files: contracts/insurance/src/lib.rs (lines 818-823, 1874-1878), contracts/insurance/src/tests.rs. Command: cargo test -p propchain-insurance.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions