-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathbillboard_test.ts
More file actions
38 lines (30 loc) · 1.54 KB
/
billboard_test.ts
File metadata and controls
38 lines (30 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Clarinet, Tx, Chain, Account, types } from 'https://deno.land/x/clarinet@v0.12.0/index.ts';
import { assertEquals } from 'https://deno.land/std@0.90.0/testing/asserts.ts';
Clarinet.test({
name: "A quick demo on how to assert expectations",
async fn(chain: Chain, accounts: Map<string, Account>) {
let deployer = accounts.get('deployer')!;
let wallet_1 = accounts.get('wallet_1')!;
let assetMaps = chain.getAssetsMaps();
const balance = assetMaps.assets['STX'][wallet_1.address];
let block = chain.mineBlock([
Tx.contractCall('billboard', 'set-message', [types.utf8("testing")], wallet_1.address),
Tx.contractCall('billboard', 'get-message', [], wallet_1.address),
Tx.contractCall('billboard', 'set-message', [types.utf8("testing...")], wallet_1.address),
Tx.contractCall('billboard', 'get-message', [], wallet_1.address),
]);
assertEquals(block.receipts.length, 4);
assertEquals(block.height, 2);
block.receipts[1].result
.expectUtf8('testing');
block.receipts[3].result
.expectUtf8('testing...');
let [event] = block.receipts[0].events;
let {sender, recipient, amount} = event.stx_transfer_event;
sender.expectPrincipal(wallet_1.address);
recipient.expectPrincipal(`${deployer.address}.billboard`);
amount.expectInt(100);
assetMaps = chain.getAssetsMaps();
assertEquals(assetMaps.assets['STX'][wallet_1.address], balance - 210);
},
});