Skip to content

feat: add deterministic refund penalty invariant coverage#536

Merged
1nonlypiece merged 2 commits into
Commitlabs-Org:masterfrom
DeePrincipal-dev-lang:feature/refund-penalty-property-tests
May 28, 2026
Merged

feat: add deterministic refund penalty invariant coverage#536
1nonlypiece merged 2 commits into
Commitlabs-Org:masterfrom
DeePrincipal-dev-lang:feature/refund-penalty-property-tests

Conversation

@DeePrincipal-dev-lang
Copy link
Copy Markdown
Contributor

Summary

Adds checked refund math and deterministic property-based coverage for escrow refund penalties.

What changed

  • Hardened early-exit refund math in contracts/escrow/src/lib.rs so penalties are computed as floor(amount * penalty_bps / 10_000) with checked arithmetic and explicit guards.
  • Reused the shared refund split helper for both direct refunds and dispute resolution.
  • Added seeded deterministic property tests in contracts/escrow/src/test.rs covering:
    • refund + penalty == amount
    • non-negative refund values
    • penalty never exceeding principal
    • penalty_bps = 0 (full refund)
    • penalty_bps = 10_000 (zero refund)
    • overflow rejection for extreme principals
    • small amount edge cases
    • randomized mid-range values using deterministic proptest input generation
  • Documented the refund math model and invariants in contracts/README.md.
  • Added proptest support and refreshed the contract lockfile.

Invariants covered

  • Principal is fully partitioned between refund and penalty.
  • Penalties stay within bounds of the principal.
  • Boundary behavior at 0% and 100% penalty is preserved.
  • Overflowed intermediate multiplication is rejected instead of wrapping.

Verification

  • cargo test --quiet in contracts/escrow passes.
  • Result: 15 passed, 0 failed.

Notes

  • Branch pushed: feature/refund-penalty-property-tests

Closes #471

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

@DeePrincipal-dev-lang is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

@1nonlypiece 1nonlypiece merged commit d4c83d3 into Commitlabs-Org:master May 28, 2026
1 check failed
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@DeePrincipal-dev-lang 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.

Contracts - Add fuzz/property tests for refund penalty math invariants

2 participants