Skip to content

feat(#321): guard emergency_pause_claim_refund on zero balance - #430

Open
iexwr wants to merge 2 commits into
Goldii-locks:mainfrom
iexwr:feat/321-empty-balance
Open

feat(#321): guard emergency_pause_claim_refund on zero balance#430
iexwr wants to merge 2 commits into
Goldii-locks:mainfrom
iexwr:feat/321-empty-balance

Conversation

@iexwr

@iexwr iexwr commented Aug 30, 2026

Copy link
Copy Markdown

Closes #321

Blocks emergency_pause_claim_refund (the admin-gated settle endpoint) while the contract token balance is zero, so an emergency refund never attempts an empty transfer.

Changes

  • Add Error::EmptyBalance (=32).
  • Add assert_nonzero_balance helper and call it from emergency_pause_claim_refund after the paused check.
  • Fund the initialised_escrow test fixture (mint to the contract via its own token id) so existing claim-refund split-math tests keep passing.
  • Add a test asserting EmptyBalance is returned for a paused but unfunded escrow.

Validation

  • cargo test for milestone-escrow: 464 passed, 0 failed.

iexwr added 2 commits August 30, 2026 16:44
- annotate test modules with #[cfg(test)] so the wasm build succeeds
  without dev-dependencies
- make setup_funded_escrow pub(crate) and fix test imports so sibling
  test modules can use it (Address::generate requires testutils trait)
- remove redundant admin.require_auth() before require_admin in
  admin_override_cancel_refund; require_admin already performs the
  signature check, and env-host 22.1.3 rejects the double auth with
  Error(Auth, ExistingValue)
- fund a terminal-state cancel test through the zero-balance boundary
  guard in cancel_escrow so its invalid-amount assertion stays intact
- add missing admin_override_cancel_tests snapshot files (untracked,
  would otherwise fail CI on a fresh checkout)
…lance

- add Error::EmptyBalance (=32) and assert_nonzero_balance helper
- reject emergency_pause_claim_refund while the contract token balance is
  zero, so an emergency settlement never attempts an empty transfer
- fund the initialized-escrow fixture mint via its own token id so the
  existing claim_refund split-math tests keep passing
- add a test asserting EmptyBalance is returned for a paused but unfunded
  escrow
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.

Handle zero/empty balances inside emergency_pause

1 participant