1
1
;; Placeholder for property-based tests.
2
2
;; Add your test cases here.
3
+
4
+ (define-constant deployer tx-sender )
5
+
6
+ (define-constant ERR_WRONG_ERROR_CODE (err u1000 ))
7
+ (define-constant ERR_ASSERTION_FAILED (err u1001 ))
8
+
9
+ (define-read-only (can-test-is-protocol-caller-ok (caller principal ))
10
+ (is-eq deployer caller)
11
+ )
12
+
13
+ (define-public (test-is-protocol-caller-ok (caller principal ))
14
+ (let
15
+ (
16
+ (is-protocol-caller-result (validate-protocol-caller caller))
17
+ )
18
+ (asserts! (is-ok is-protocol-caller-result) ERR_ASSERTION_FAILED)
19
+ (ok true )
20
+ )
21
+ )
22
+
23
+ (define-read-only (can-test-is-protocol-caller-err (caller principal ))
24
+ (not (is-eq deployer caller))
25
+ )
26
+
27
+ (define-public (test-is-protocol-caller-err (caller principal ))
28
+ (let
29
+ (
30
+ (unwrap-error (err u9999 ))
31
+ (is-protocol-caller-result (validate-protocol-caller caller))
32
+ )
33
+ (asserts!
34
+ (and
35
+ (is-err is-protocol-caller-result)
36
+ (is-eq
37
+ (unwrap-err! is-protocol-caller-result unwrap-error)
38
+ u400
39
+ )
40
+ )
41
+ ERR_ASSERTION_FAILED
42
+ )
43
+ (ok true )
44
+ )
45
+ )
46
+
47
+ (define-read-only (can-test-complete-withdrawal-reject
48
+ (request-id uint )
49
+ (signer-bitmap uint )
50
+ )
51
+ (is-eq deployer contract-caller )
52
+ )
53
+
54
+ (define-public (test-complete-withdrawal-reject
55
+ (request-id uint )
56
+ (signer-bitmap uint )
57
+ )
58
+ (begin
59
+ (try! (complete-withdrawal-reject request-id signer-bitmap))
60
+ (asserts!
61
+ (is-eq
62
+ (unwrap-panic (map-get? withdrawal-status request-id))
63
+ false
64
+ )
65
+ ERR_ASSERTION_FAILED
66
+ )
67
+ (ok true )
68
+ )
69
+ )
70
+
71
+ (define-read-only (can-test-withdrawal-req-id-incremented
72
+ (amount uint )
73
+ (max-fee uint )
74
+ (sender principal )
75
+ (recipient { version : (buff 1 ), hashbytes : (buff 32 ) })
76
+ (height uint )
77
+ )
78
+ (is-eq contract-caller deployer)
79
+ )
80
+
81
+ (define-public (test-withdrawal-req-id-incremented
82
+ (amount uint )
83
+ (max-fee uint )
84
+ (sender principal )
85
+ (recipient { version : (buff 1 ), hashbytes : (buff 32 ) })
86
+ (height uint )
87
+ )
88
+ (let (
89
+ (last-withdrawal-req-id-before (var-get last-withdrawal-request-id ))
90
+ )
91
+ (try! (create-withdrawal-request amount max-fee sender recipient height))
92
+ (asserts!
93
+ (is-eq
94
+ (var-get last-withdrawal-request-id )
95
+ (+ last-withdrawal-req-id-before u1 )
96
+ )
97
+ ERR_ASSERTION_FAILED
98
+ )
99
+ (ok true )
100
+ )
101
+ )
102
+
103
+ (define-read-only (can-test-withdrawal-req-id-non-deployer
104
+ (amount uint )
105
+ (max-fee uint )
106
+ (sender principal )
107
+ (recipient { version : (buff 1 ), hashbytes : (buff 32 ) })
108
+ (height uint )
109
+ )
110
+ (not (is-eq contract-caller deployer))
111
+ )
112
+
113
+ (define-public (test-withdrawal-req-id-non-deployer
114
+ (amount uint )
115
+ (max-fee uint )
116
+ (sender principal )
117
+ (recipient { version : (buff 1 ), hashbytes : (buff 32 ) })
118
+ (height uint )
119
+ )
120
+ (let (
121
+ (unwrap-error (err u9999 ))
122
+ (withdrawal-request-result
123
+ (create-withdrawal-request amount max-fee sender recipient height)
124
+ )
125
+ )
126
+ (asserts!
127
+ (is-eq
128
+ (unwrap-err! withdrawal-request-result unwrap-error)
129
+ u400
130
+ )
131
+ ERR_ASSERTION_FAILED
132
+ )
133
+ (ok true )
134
+ )
135
+ )
136
+
137
+ (define-read-only (can-test-withdrawal-req-id-not-updated-non-deployer
138
+ (amount uint )
139
+ (max-fee uint )
140
+ (sender principal )
141
+ (recipient { version : (buff 1 ), hashbytes : (buff 32 ) })
142
+ (height uint )
143
+ )
144
+ (not (is-eq contract-caller deployer))
145
+ )
146
+
147
+ (define-public (test-withdrawal-req-id-not-updated-non-deployer
148
+ (amount uint )
149
+ (max-fee uint )
150
+ (sender principal )
151
+ (recipient { version : (buff 1 ), hashbytes : (buff 32 ) })
152
+ (height uint )
153
+ )
154
+ (let (
155
+ (last-withdrawal-req-id-before (var-get last-withdrawal-request-id ))
156
+ )
157
+ (asserts!
158
+ (is-eq
159
+ (var-get last-withdrawal-request-id )
160
+ last-withdrawal-req-id-before
161
+ )
162
+ ERR_ASSERTION_FAILED
163
+ )
164
+ (ok true )
165
+ )
166
+ )
0 commit comments