Skip to content

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

Description

@Jagadeeshftw

📌 Description

set_max_settlement_amount(asset, amount) documents 0 as disabling the cap per the README's table, mirroring set_min_liquidity's 0-disables-floor convention. This "0 means disabled" sentinel is a common source of off-by-one bugs (e.g. accidentally treating 0 as "cap of zero, reject everything") and deserves an explicit named test rather than incidental coverage.

🧩 Requirements and context

  • Add a test: with max_settlement_amount(asset) at 0, open a large settlement via open_settlement and assert it succeeds (cap is disabled, not zero).
  • Add a companion test with a nonzero cap confirming a settlement exceeding it is correctly rejected.
  • Cross-check set_min_liquidity's equivalent 0 sentinel has the same explicit test coverage; add it if missing.

🛠️ Suggested execution

  • Add both tests to src/test.rs.
  • Fix open_settlement's cap-check logic in src/lib.rs if the 0 sentinel is mishandled.

✅ Acceptance criteria

  • 0 correctly disables the settlement-amount cap.
  • A nonzero cap correctly rejects an over-cap settlement.
  • Both scenarios covered by named regression tests, including the min_liquidity equivalent.

🔒 Security notes

An inverted sentinel here would either silently disable a risk control or brick settlements entirely for an asset — worth locking down explicitly.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuetestingTests and coverage

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions