Skip to content

Commit

Permalink
Add dust amount test for initiate-withdrawal-request
Browse files Browse the repository at this point in the history
  • Loading branch information
BowTiedRadone authored and moodmosaic committed Jan 30, 2025
1 parent 1167ba1 commit 72fbfdf
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions contracts/contracts/sbtc-withdrawal.tests.clar
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
;; Properties

(define-constant ERR_ASSERTION_FAILED (err u1001))
(define-constant ERR_UNWRAP_FAILURE (err u1002))

(define-constant deployer tx-sender)
(define-constant dust_limit_error_code u502)

;; This is a test utility, not an assertion. It randomly mints sbtc-tokens to
;; users, supporting other tests.
Expand Down Expand Up @@ -95,4 +97,42 @@
(ok true)
)
)
)

(define-public (test-initiate-withdrawal-dust-amount
(amount uint)
(recipient { version: (buff 1), hashbytes: (buff 32) })
(max-fee uint)
)
(if
(or
(is-eq amount u0)
(> amount DUST_LIMIT)
(<
(unwrap-panic
(contract-call? .sbtc-token get-balance-available tx-sender)
)
(+ amount max-fee)
)
)
(ok false)
(let
(
(withdrawal-request-result
(initiate-withdrawal-request amount recipient max-fee)
)
)
(asserts!
(and
(is-err withdrawal-request-result)
(is-eq
(unwrap-err! withdrawal-request-result ERR_UNWRAP_FAILURE)
dust_limit_error_code
)
)
ERR_ASSERTION_FAILED
)
(ok true)
)
)
)

0 comments on commit 72fbfdf

Please sign in to comment.