test(#50): property-based invariant tests for leverage math#235
Open
obanai9 wants to merge 1 commit into
Open
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements issue #50 — D9: Property / invariant tests for leverage math.
Cargo.toml: addsproptest = "1"to dev-dependencies.src/test_proptest.rswithProptestConfig::with_cases(1_000)— seven invariants:total_supply >= total_borrow(borrow never exceeds supply)total_supply - total_borrow == initial(net equity preserved)total_supply <= initial / (1 − c)(geometric-series upper bound)c_factor(higher c → strictly higher HF)compute_stepsupply leg always equalsbalancecompute_stepfinal borrow is exactly 0checked_mul)Test plan
cargo test -p blend_leverage_strategy— proptest runs 1 000 cases per property, all pass.Closes #50
🤖 Generated with Claude Code