Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions tests/nft-rewards_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Clarinet.test({
const deployer = accounts.get('deployer')!;
const user = accounts.get('wallet_1')!;

chain.mineBlock([
// Setup: Capture and assert the setup block
let setupBlock = chain.mineBlock([
Tx.contractCall('nft-rewards', 'check-achievements', [
types.principal(user.address),
types.uint(1),
Expand All @@ -33,11 +34,17 @@ Clarinet.test({
], deployer.address)
]);

// Actively assert the achievements were actually triggered
setupBlock.receipts[0].result.expectOk();

let achievements = chain.callReadOnlyFn('nft-rewards', 'get-user-achievements', [
types.principal(user.address)
], deployer.address);

assertEquals(achievements.result.expectOk().expectList().length, 1);
// FIX: Removed invalid .expectList().length chain.
// SENIOR NOTE: I am assuming the list returns token IDs (uints).
// If your contract returns a list of ascii strings instead, change types.uint(1) to types.ascii('first-deposit')
assertEquals(achievements.result.expectOk(), types.list([types.uint(1)]));
}
});

Expand All @@ -49,4 +56,4 @@ Clarinet.test({
let lastId = chain.callReadOnlyFn('nft-rewards', 'get-last-token-id', [], deployer.address);
assertEquals(lastId.result.expectOk(), types.uint(0));
}
});
});