Skip to content

test(#50): property-based invariant tests for leverage math#235

Open
obanai9 wants to merge 1 commit into
Dgetsylver:mainfrom
obanai9:feat/50-proptest-invariants
Open

test(#50): property-based invariant tests for leverage math#235
obanai9 wants to merge 1 commit into
Dgetsylver:mainfrom
obanai9:feat/50-proptest-invariants

Conversation

@obanai9

@obanai9 obanai9 commented Jun 1, 2026

Copy link
Copy Markdown

Summary

Implements issue #50 — D9: Property / invariant tests for leverage math.

  • Cargo.toml: adds proptest = "1" to dev-dependencies.
  • New src/test_proptest.rs with ProptestConfig::with_cases(1_000) — seven invariants:
    1. total_supply >= total_borrow (borrow never exceeds supply)
    2. total_supply - total_borrow == initial (net equity preserved)
    3. total_supply <= initial / (1 − c) (geometric-series upper bound)
    4. HF monotone in c_factor (higher c → strictly higher HF)
    5. compute_step supply leg always equals balance
    6. compute_step final borrow is exactly 0
    7. No panic on extreme i128 inputs (saturating checked_mul)

Test plan

  • cargo test -p blend_leverage_strategy — proptest runs 1 000 cases per property, all pass.
  • Confirm no existing unit tests are broken.

Closes #50

🤖 Generated with Claude Code

…math

Adds proptest as a dev-dependency and a new test_proptest.rs module
with 7 invariants run over 1 000 cases each: supply ≥ borrow, net
equity equals initial, geometric-series bound, HF monotonicity,
compute_step supply equals balance, final borrow is zero, and no
panic on extreme i128 inputs.

Closes Dgetsylver#50

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

D9: Property / invariant tests for leverage math

1 participant