Skip to content

Commit fb77047

Browse files
committed
Update csw-registry Rendezvous tests
1 parent 44d3205 commit fb77047

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

contracts/csw-registry.tests.clar

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
;; PROPERTY-BASED TESTS
33
;; ============================================
44

5-
(define-public (test-register (csw <csw-trait>))
5+
(define-public (test-register-valid-csw (csw <csw-trait>))
66
(let (
77
(csw-contract (contract-of csw))
88
)
@@ -12,6 +12,13 @@
1212
(is-some (map-get? csw-to-index csw-contract))
1313
;; The tx-sender is not the owner of the csw.
1414
(not (is-eq (unwrap-panic (contract-call? csw get-owner)) tx-sender))
15+
;; Discard invalid csw implementations.
16+
(not
17+
(is-eq
18+
(contract-hash? (contract-of csw))
19+
(contract-hash? .smart-wallet-standard)
20+
)
21+
)
1522
)
1623
;; Discard invalid inputs.
1724
(ok false)
@@ -43,6 +50,36 @@
4350
)
4451
)
4552

53+
(define-public (test-register-invalid-csw (csw <csw-trait>))
54+
(let (
55+
(csw-contract (contract-of csw))
56+
)
57+
(if
58+
(or
59+
;; The csw is already registered.
60+
(is-some (map-get? csw-to-index csw-contract))
61+
;; The tx-sender is not the owner of the csw.
62+
(not (is-eq (unwrap-panic (contract-call? csw get-owner)) tx-sender))
63+
;; Discard valid csw implementations.
64+
(is-eq
65+
(contract-hash? (contract-of csw))
66+
(contract-hash? .smart-wallet-standard)
67+
)
68+
)
69+
;; Discard invalid inputs.
70+
(ok false)
71+
(let (
72+
(index-before (var-get csw-index))
73+
(has-primary-csw-before (is-some (map-get? primary-csw tx-sender)))
74+
(register-error (unwrap-err! (csw-register csw) (err u998)))
75+
)
76+
(asserts! (is-eq (err register-error) ERR-INVALID-CSW-CONTRACT) (err u999))
77+
(ok true)
78+
)
79+
)
80+
)
81+
)
82+
4683
(define-public (test-transfer (csw <csw-trait>) (recipient principal))
4784
(let (
4885
(wallet-owner (unwrap-panic (contract-call? csw get-owner)))

0 commit comments

Comments
 (0)