Skip to content

Commit cb76bb2

Browse files
committed
fix: Update contract initialization and error handling in DAO extension tests
This commit addresses several test failures in the aibtc-ext001-actions contract by: - Fixing contract names in Clarinet.toml - Reordering checks in vote-on-proposal - Correcting token initialization logic - Updating treasury validation checks - Adjusting error handling for various scenarios The changes ensure proper contract initialization, error propagation, and validation of contract state before performing actions.
1 parent ea9a505 commit cb76bb2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Clarinet.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ epoch = 2.5
9797

9898
# testing utilities
9999

100-
[contracts.test-abitc-treasury]
100+
[contracts.test-treasury]
101101
path = 'contracts/test/aibtc-treasury.clar'
102102
clarity_version = 2
103103
epoch = 2.5
@@ -118,7 +118,7 @@ path = 'contracts/test/proxy.clar'
118118
clarity_version = 2
119119
epoch = 2.5
120120

121-
[contracts.test-sip010-token]
121+
[contracts.test-token]
122122
path = 'contracts/test/sip010-token.clar'
123123
clarity_version = 2
124124
epoch = 2.5

contracts/dao/extensions/aibtc-ext001-actions.clar

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@
119119
(try! (is-dao-or-extension))
120120
;; treasury must be a contract
121121
(asserts! (not (is-standard treasuryContract)) ERR_TREASURY_MUST_BE_CONTRACT)
122+
;; treasury must not be already set
123+
(asserts! (is-eq (var-get protocolTreasury) SELF) ERR_TREASURY_NOT_INITIALIZED)
122124
;; treasury cannot be the voting contract
123125
(asserts! (not (is-eq treasuryContract SELF)) ERR_TREASURY_CANNOT_BE_SELF)
124-
;; treasury cannot be the same value
125-
(asserts! (not (is-eq treasuryContract (var-get protocolTreasury))) ERR_TREASURY_ALREADY_SET)
126126
(print {
127127
notification: "set-protocol-treasury",
128128
payload: {
@@ -141,8 +141,8 @@
141141
(try! (is-dao-or-extension))
142142
;; token must be a contract
143143
(asserts! (not (is-standard tokenContract)) ERR_TOKEN_MUST_BE_CONTRACT)
144+
;; token must not be already set
144145
(asserts! (is-eq (var-get votingToken) SELF) ERR_TOKEN_NOT_INITIALIZED)
145-
(asserts! (is-eq (var-get votingToken) tokenContract) ERR_TOKEN_MISMATCH)
146146
(print {
147147
notification: "set-voting-token",
148148
payload: {
@@ -199,7 +199,6 @@
199199
(define-public (vote-on-proposal (proposalId uint) (token <ft-trait>) (vote bool))
200200
(let
201201
(
202-
(proposalRecord (unwrap! (map-get? Proposals proposalId) ERR_PROPOSAL_NOT_FOUND))
203202
(tokenContract (contract-of token))
204203
(senderBalance (try! (contract-call? token get-balance tx-sender)))
205204
)
@@ -208,7 +207,12 @@
208207
;; token matches set voting token
209208
(asserts! (is-eq tokenContract (var-get votingToken)) ERR_TOKEN_MISMATCH)
210209
;; caller has the required balance
211-
(asserts! (> senderBalance u0) ERR_ZERO_VOTING_POWER)
210+
(asserts! (> senderBalance u0) ERR_INSUFFICIENT_BALANCE)
211+
;; get proposal record
212+
(let
213+
(
214+
(proposalRecord (unwrap! (map-get? Proposals proposalId) ERR_PROPOSAL_NOT_FOUND))
215+
)
212216
;; proposal is still active
213217
(asserts! (>= burn-block-height (get startBlock proposalRecord)) ERR_VOTE_TOO_SOON)
214218
(asserts! (< burn-block-height (get endBlock proposalRecord)) ERR_VOTE_TOO_LATE)

0 commit comments

Comments
 (0)