Skip to content

test: pin prediction-market resolution, insurance premium engine, factory and sanctions threshold paths - #1056

Merged
nanaf6203-bit merged 2 commits into
MettaChain:mainfrom
Hassan-oladipupo:feature/unit-tests-prediction-market-insurance-factory-sanctions
Aug 25, 2026
Merged

test: pin prediction-market resolution, insurance premium engine, factory and sanctions threshold paths#1056
nanaf6203-bit merged 2 commits into
MettaChain:mainfrom
Hassan-oladipupo:feature/unit-tests-prediction-market-insurance-factory-sanctions

Conversation

@Hassan-oladipupo

Copy link
Copy Markdown
Contributor

Summary

Pins four previously untested paths with unit tests: prediction-market resolution (#1017), insurance premium engine (#1018), factory deployment/admin (#1019) and sanctions screening threshold (#1020).

What's covered

Issue Crate Coverage
#1017 prediction-market resolve admin gate, pre-deadline resolve + post-deadline stake rejections, long wins at target value, double-resolution rejected, winner payout = proportional minus fee (balance delta + RewardClaimed event), loser gets nothing + reputation penalty, double/non-participant/pre-resolution claim rejections
#1018 insurance direct calculate_premium / calculate_premium_with_modifiers tests with fixed inputs asserting exact values: baseline across all seven multipliers, every modifier branch (multi-policy, claim-free, safety+deductible, loyalty, recent-claims surcharge incl. cap-at-5), 40% total-discount cap, duration proration buckets, rounding truncation, PropertyNotInsurable/pool-not-found errors
#1019 factory deploy_contract without registered hash → CodeHashNotSet; change_admin transfers rights & revokes old admin; non-admin rejection; deployment getters reflect recorded deployments
#1020 sanctions set_screening_threshold non-admin rejection (value stays 90), admin update + round-trip via getter, SanctionThresholdUpdated event asserted

No business logic changed — tests only.

Testing

  • cargo test -p propchain-prediction-market → 20 passed
  • cargo test -p propchain-insurance → 109 passed
  • cargo test -p propchain-factory → 14 passed
  • cargo test -p propchain-sanctions → 13 passed

Closes #1017
Closes #1018
Closes #1019
Closes #1020

…tory admin and sanctions threshold paths

- Prediction market (MettaChain#1017): resolution-flow coverage — admin gate,
  resolve before deadline rejected, staking after the resolution deadline
  rejected, long side wins when resolved value equals target, double
  resolution rejected, winner claim pays the proportional payout minus
  the protocol fee (balance delta + RewardClaimed event asserted), loser
  claim yields nothing with a reputation penalty, double claim and
  non-participant claims rejected, claim-before-resolution rejected.
- Insurance premium engine (MettaChain#1018): direct tests of calculate_premium /
  calculate_premium_with_modifiers through the public messages with fixed
  inputs asserting exact values: baseline fire/one-year across all seven
  multipliers (annual/monthly/deductible/breakdown), each modifier branch
  (multiple-policy discount, claim-free years, safety features +
  deductible, loyalty, recent-claims surcharge incl. per-event cap at
  five), total-discount cap at forty percent, duration proration
  (half-year / one-month buckets), rounding truncation, and the
  PropertyNotInsurable / pool-not-found error paths.
- Factory (MettaChain#1019): deploy_contract without a registered code hash fails
  with CodeHashNotSet; change_admin transfers rights and revokes the old
  admin; non-admin change rejected; deployment getters reflect recorded
  deployments.
- Sanctions (MettaChain#1020): set_screening_threshold non-admin rejection (value
  stays 90), admin update to 30 with round-trip via screening_threshold,
  and SanctionThresholdUpdated event emission asserted.

No business logic changed — tests only.

All green: prediction-market 20, insurance 109, factory 14,
sanctions 13 passed.

Closes MettaChain#1017
Closes MettaChain#1018
Closes MettaChain#1019
Closes MettaChain#1020
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@Hassan-oladipupo 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

@nanaf6203-bit
nanaf6203-bit merged commit 086e57c into MettaChain:main Aug 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment