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
- 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.
- 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.
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.rsenforces pool exposure throughmax_coverage_ratio:create_policyandcreate_parametric_policycomputemax_exposure = pool.available_capital.saturating_mul(pool.max_coverage_ratio) / 10_000and reject withInsufficientPoolFundswhencoverage_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 theInsufficientPoolFundsrejection 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_000truncation) either over-approves risk or rejects valid policies.Why this is architecturally hard
available_capital * ratio / 10_000truncates; tests must pin the exactly-at-ratio and one-unit-above cases so a rounding change is caught.Acceptance criteria
InsufficientPoolFunds), and the pool's capital after acceptance.cargo test -p propchain-insurancepasses.Getting started
Files:
contracts/insurance/src/lib.rs(lines 818-823, 1874-1878),contracts/insurance/src/tests.rs. Command:cargo test -p propchain-insurance.