From 65c244f9f54f501494fdfdaf5db291903d76d457 Mon Sep 17 00:00:00 2001 From: Jadonamite Date: Sun, 29 Mar 2026 18:09:55 +0100 Subject: [PATCH] test: enforce setup block assertions in emergency contract tests Updates the emergency contract test suite to capture and explicitly assert the success of setup transactions. Ensures the contract successfully enters the paused state before querying the pause status or attempting to resume operations, preventing confusing test failures caused by silent setup errors. --- tests/emergency_test.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/emergency_test.ts b/tests/emergency_test.ts index 148355fc..6870ca1c 100644 --- a/tests/emergency_test.ts +++ b/tests/emergency_test.ts @@ -21,12 +21,16 @@ Clarinet.test({ async fn(chain: Chain, accounts: Map) { const deployer = accounts.get('deployer')!; - chain.mineBlock([ + // Capture the setup block + let setupBlock = chain.mineBlock([ Tx.contractCall('emergency', 'emergency-pause', [ types.ascii('Test pause') ], deployer.address) ]); + // Actively assert the setup succeeded before querying state + setupBlock.receipts[0].result.expectOk(); + let status = chain.callReadOnlyFn('emergency', 'is-paused', [], deployer.address); assertEquals(status.result.expectOk(), types.bool(true)); } @@ -37,16 +41,20 @@ Clarinet.test({ async fn(chain: Chain, accounts: Map) { const deployer = accounts.get('deployer')!; - chain.mineBlock([ + // Capture the setup block + let setupBlock = chain.mineBlock([ Tx.contractCall('emergency', 'emergency-pause', [ types.ascii('Test pause') ], deployer.address) ]); + // Actively assert the setup succeeded before trying to resume + setupBlock.receipts[0].result.expectOk(); + let block = chain.mineBlock([ Tx.contractCall('emergency', 'resume-operations', [], deployer.address) ]); assertEquals(block.receipts[0].result.expectOk(), types.uint(1)); } -}); \ No newline at end of file +});