Commit 0495082
authored
test(collateral): add edge-case unit suite for CollateralManager (#348)
Covers all five boundary cases from issue #260:
- collateral_value == 0 → health factor is INFINITE_HEALTH (no debt)
- borrowed_value == 0 → health factor is INFINITE_HEALTH
- collateral_factor == 1 → calculate_max_leverage raises ValueError
- liquidation_threshold == 0 → calculate_liquidation_price raises ValueError
- max_withdraw > collateral_value → result clamped to Decimal(0)
Also adds:
- Negative input guard tests for all calculation methods
- evaluate_position integration smoke tests
- XLM_ASSET_ID / USDC_ASSET_ID / ETH_ASSET_ID / IS_MAINNET constants
in contract_tools/constants.py (required by CollateralManager)
34 tests added, all passing.
Closes #260
Co-authored-by: Spaully <Spaully@users.noreply.github.com>1 parent 976aad3 commit 0495082
2 files changed
Lines changed: 455 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
41 | 67 | | |
42 | 68 | | |
43 | 69 | | |
| |||
0 commit comments