diff --git a/contracts/stableswap-stackingDAO.clar b/contracts/stableswap-stackingDAO.clar index 2897f6b..c65f14f 100644 --- a/contracts/stableswap-stackingDAO.clar +++ b/contracts/stableswap-stackingDAO.clar @@ -1063,6 +1063,7 @@ ) ;; Assert that tx-sender is an admin using is-some & index-of with the admins var (asserts! (is-some (index-of current-admins tx-sender)) (err "err-not-admin")) + (asserts! (> new-convergence-threshold u0) (err "err-invalid-convergence-threshold")) (ok (var-set convergence-threshold new-convergence-threshold)) ) diff --git a/tests/stableswap-stackingDAO_test.ts b/tests/stableswap-stackingDAO_test.ts index 4e75bb3..8cb089d 100644 --- a/tests/stableswap-stackingDAO_test.ts +++ b/tests/stableswap-stackingDAO_test.ts @@ -1606,4 +1606,36 @@ Clarinet.test({ block.receipts[0].result.expectErr() console.log(JSON.stringify(block.receipts)); }, -}); \ No newline at end of file +}); + +// Test convergence threshold admin controls +Clarinet.test({ + name: "Ensure admins cannot set convergence threshold to zero", + async fn(chain: Chain, accounts: Map) { + const deployer = accounts.get("deployer")!; + const wallet_1 = accounts.get("wallet_1")!; + + const block = chain.mineBlock([ + Tx.contractCall("stableswap-stackingDAO", "change-convergence-threshold", [types.uint(0)], deployer.address) + ]); + + block.receipts[0].result.expectErr() + console.log(JSON.stringify(block.receipts)); + }, +}); + +// Test convergence threshold admin controls +Clarinet.test({ + name: "Ensure admins can set convergence threshold above zero", + async fn(chain: Chain, accounts: Map) { + const deployer = accounts.get("deployer")!; + const wallet_1 = accounts.get("wallet_1")!; + + const block = chain.mineBlock([ + Tx.contractCall("stableswap-stackingDAO", "change-convergence-threshold", [types.uint(1)], deployer.address) + ]); + + block.receipts[0].result.expectOk() + console.log(JSON.stringify(block.receipts)); + }, +});