test: rate clamp ordering proptest - #1
Open
iexwr wants to merge 1 commit into
Open
Conversation
Add property-based tests to verify that per-borrower rate clamping is order-independent across operations. Includes: - prop_clamp_modularity: verifies max(min(r,c),f) == min(max(r,f),c) for 1024 random (rate, floor, ceiling) triples - prop_clamp_contract_integration: end-to-end contract test (256 cases) matching update_risk_parameters output to the mathematical clamp - prop_clamp_floor_ceiling_set_order: verifies setting floor/ceiling in either order yields the same final rate (128 cases) - 8 deterministic edge-case tests covering zero bounds, global cap, degenerate ranges, floor-only, ceiling-only, and no-bounds paths Also fixes a pre-existing compilation error in query.rs where u128::from(i128) was used, which is not a valid conversion.
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
Adds property-based tests verifying that per-borrower rate clamping is order-independent across operations.
Tests Added
prop_clamp_modularitymax(min(r,c),f) == min(max(r,f),c)for all validf ≤ cprop_clamp_contract_integrationprop_clamp_floor_ceiling_set_orderclamp_zero_boundsclamp_global_cap_boundaryclamp_floor_exceeds_ceilingclamp_no_boundsclamp_floor_onlyclamp_ceiling_onlyclamp_modularity_deterministicclamp_modularity_boundary_sweepVerification
cargo test -p creditra-credit --test proptest_rate_clamp- all 11 tests passcargo check -p creditra-credit- no new warningscargo clippy- no new warningsAlso fixes a pre-existing compilation error in
query.rs(u128::from(i128)is invalid; changed toas u128).Closes Creditra#585