From ae44eff737cfee0cc0714a0b8d56dfd7babbcdbb Mon Sep 17 00:00:00 2001 From: Jadonamite Date: Sun, 29 Mar 2026 15:56:05 +0100 Subject: [PATCH] test: add missing assertions for setup blocks in analytics tests Updates the "tracks user activity" test to capture the mined setup block and actively assert that the record-deposit transaction succeeds before querying the read-only function. This is a critical testing practice to prevent silent failures during test setup from causing confusing downstream errors (like .expectSome() failing because the deposit never actually happened). --- tests/analytics_test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/analytics_test.ts b/tests/analytics_test.ts index 4b75f402..7c840377 100644 --- a/tests/analytics_test.ts +++ b/tests/analytics_test.ts @@ -24,13 +24,18 @@ Clarinet.test({ const deployer = accounts.get('deployer')!; const user = accounts.get('wallet_1')!; - chain.mineBlock([ + // Capture the setup block + let setupBlock = chain.mineBlock([ Tx.contractCall('analytics', 'record-deposit', [ types.principal(user.address), types.uint(500000) ], deployer.address) ]); + // Actively assert the setup transaction actually succeeded + // If this fails, the test stops here, preventing confusing errors below + setupBlock.receipts[0].result.expectOk(); + let activity = chain.callReadOnlyFn('analytics', 'get-user-activity', [ types.principal(user.address) ], deployer.address); @@ -38,4 +43,4 @@ Clarinet.test({ const result = activity.result.expectSome().expectTuple(); assertEquals(result['deposits'], types.uint(500000)); } -}); \ No newline at end of file +});