#102 Medium: Insufficient Edge Case Coverage for Financial Bounds#127
Open
coder45oj wants to merge 2 commits into
Open
#102 Medium: Insufficient Edge Case Coverage for Financial Bounds#127coder45oj wants to merge 2 commits into
coder45oj wants to merge 2 commits into
Conversation
Add comprehensive edge case and boundary tests for the pool contract, covering extreme u128 values, minimum positive increments, and financial bounds that were previously untested. Tests added: - test_edge_min_deposit_and_withdraw: 1 USDC deposit → 1 share → withdraw - test_edge_large_deposit_near_u128_max: i128::MAX value deposit+withdraw - test_edge_deposit_overflow_panics: confirm checked_mul catches overflow - test_edge_withdraw_overflow_panics: confirm checked_mul catches overflow - test_edge_fund_repay_with_zero_discount: 0 bps discount → no yield - test_edge_fund_repay_with_max_discount: 5000 bps discount → 50% yield - test_edge_fund_default_at_min_deposit: 100% utilization then default+redeposit - test_edge_split_fund_two_invoices_min_liquidity: fund to 0 available - test_edge_withdraw_exact_available_liquidity: withdraw exactly the liquid amount - test_edge_max_utilization_rate_boundaries: 0% and 100% utilization - test_edge_deposit_after_partial_default_with_remainder_shares: deposit below par Closes TrusTrove#102
|
@coder45oj 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! 🚀 |
Contributor
|
fixe the ci error @coder45oj |
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.
Description
Adds comprehensive edge case and boundary tests for the pool contract, covering extreme
u128values, minimum positive increments, and financial bounds previously untested.Changes
contracts/pool/src/test.rs— Added 11 edge case tests and a parameterizedcreate_and_list_exthelper:Overflow Protection
test_edge_deposit_overflow_panics— Verifieschecked_mulindeposit()catches overflow whenusdc_amount * total_shares > u128::MAXtest_edge_withdraw_overflow_panics— Verifieschecked_mulinwithdraw()catches overflow whenshares * total_deposits > u128::MAXBoundary Values
test_edge_min_deposit_and_withdraw— Minimum 1 USDC deposit and withdrawal at 1:1 pricetest_edge_large_deposit_near_u128_max— i128::MAX deposit/withdrawal (largest value MockToken can hold)Extreme Discount Scenarios
test_edge_fund_repay_with_zero_discount— Invoice with 0 bps discount (funded at 100% face value, zero yield)test_edge_fund_repay_with_max_discount— Invoice with 5000 bps max discount (funded at 50%, 10B yield)Financial Bounds
test_edge_fund_default_at_min_deposit— 100% utilization (9.8B deposit fully funded), then default and re-deposit after total_deposits = 0test_edge_split_fund_two_invoices_min_liquidity— Fund to 0 available liquidity, then repay one to restoretest_edge_withdraw_exact_available_liquidity— Withdraw exactly the available liquidity amount, leaving shares backing funded invoicestest_edge_max_utilization_rate_boundaries— Verify 0% and 10000 bps (100%) utilization ratestest_edge_deposit_after_partial_default_with_remainder_shares— New LP deposits at below-par share price after default erodes pool valueCloses #102