Skip to content

test: lock down the 0-disables sentinel for settlement cap and liquidity floor - #179

Open
mordabdul1 wants to merge 1 commit into
AnchorNet-Org:mainfrom
mordabdul1:test/zero-sentinel-caps-81
Open

mordabdul1 wants to merge 1 commit into
AnchorNet-Org:mainfrom
mordabdul1:test/zero-sentinel-caps-81

Conversation

@mordabdul1

Copy link
Copy Markdown

Summary

Closes #81.

Adds explicit named regression tests for the "0 disables" sentinel on both limits that share the convention, covering the sharpest inversion risk: resetting an active limit back to 0 (not just the never-configured default).

Tests added

  • test_max_settlement_amount_zero_sentinel_disables_cap — sets a 500 cap and asserts a 600 settlement is rejected with AboveMaxSettlementAmount; then resets the cap to 0 and asserts a settlement for the entire pool (1,000, double the former cap) succeeds. 0 means "no cap", never "cap of zero, reject everything".
  • test_min_liquidity_zero_sentinel_disables_floor — the cross-checked min_liquidity equivalent: an active 700 floor rejects a withdrawal with BelowMinLiquidity; resetting the floor to 0 lets the pool drain to exactly zero.

Both scenarios the issue names were already partially covered (test_max_settlement_amount_disabled_by_default for the untouched default, test_open_settlement_rejects_amount_above_cap / test_open_settlement_allows_amount_at_cap for nonzero-cap enforcement including the at-cap boundary); those remain unchanged, and the new tests add the explicit active→0 transition neither covered.

Review of the sentinel logic (no gap found)

  • open_settlement guards with cap > 0 && amount > cap (src/lib.rs), so a zero cap short-circuits cleanly.
  • require_min_liquidity early-returns Ok on floor == 0.

No fix needed in src/lib.rs.

Testing

Full suite: 155 passed, 0 failed. cargo fmt --check clean.

Incidental

Bumps ethnum 1.5.2 → 1.5.3 in Cargo.lock (1.5.2 fails to compile on recent rustc, E0512). Same patch bump as the other open PRs; merges cleanly in any order.

@mordabdul1
mordabdul1 force-pushed the test/zero-sentinel-caps-81 branch from 9d0ff4b to 9f44526 Compare October 23, 2026 12:57
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.

Add explicit regression test for the max_settlement_amount(asset, 0) disables-cap sentinel

1 participant