Skip to content

Commit 72fbfdf

Browse files
BowTiedRadonemoodmosaic
authored andcommitted
Add dust amount test for initiate-withdrawal-request
1 parent 1167ba1 commit 72fbfdf

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

contracts/contracts/sbtc-withdrawal.tests.clar

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
;; Properties
22

33
(define-constant ERR_ASSERTION_FAILED (err u1001))
4+
(define-constant ERR_UNWRAP_FAILURE (err u1002))
45

56
(define-constant deployer tx-sender)
7+
(define-constant dust_limit_error_code u502)
68

79
;; This is a test utility, not an assertion. It randomly mints sbtc-tokens to
810
;; users, supporting other tests.
@@ -95,4 +97,42 @@
9597
(ok true)
9698
)
9799
)
100+
)
101+
102+
(define-public (test-initiate-withdrawal-dust-amount
103+
(amount uint)
104+
(recipient { version: (buff 1), hashbytes: (buff 32) })
105+
(max-fee uint)
106+
)
107+
(if
108+
(or
109+
(is-eq amount u0)
110+
(> amount DUST_LIMIT)
111+
(<
112+
(unwrap-panic
113+
(contract-call? .sbtc-token get-balance-available tx-sender)
114+
)
115+
(+ amount max-fee)
116+
)
117+
)
118+
(ok false)
119+
(let
120+
(
121+
(withdrawal-request-result
122+
(initiate-withdrawal-request amount recipient max-fee)
123+
)
124+
)
125+
(asserts!
126+
(and
127+
(is-err withdrawal-request-result)
128+
(is-eq
129+
(unwrap-err! withdrawal-request-result ERR_UNWRAP_FAILURE)
130+
dust_limit_error_code
131+
)
132+
)
133+
ERR_ASSERTION_FAILED
134+
)
135+
(ok true)
136+
)
137+
)
98138
)

0 commit comments

Comments
 (0)