Skip to content

Commit 61ee64a

Browse files
committed
feat: initial tests for .sip-031
1 parent 7906fa2 commit 61ee64a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { project, accounts } from '../clarigen-types'; // where your [types.output] was specified
2+
import { projectFactory } from '@clarigen/core';
3+
import { rov, txErr, txOk } from '@clarigen/test';
4+
import { test, expect } from 'vitest';
5+
6+
const contracts = projectFactory(project, 'simnet');
7+
const contract = contracts.sip031;
8+
const constants = contract.constants;
9+
10+
test('initial recipient should be the deployer', () => {
11+
const value = rov(contract.getRecipient());
12+
expect(value).toBe(accounts.deployer.address);
13+
})
14+
15+
test('only the recigpient can update the recipient', () => {
16+
const receipt = txErr(contract.updateRecipient(accounts.wallet_1.address), accounts.wallet_1.address)
17+
18+
expect(receipt.value).toBe(constants.ERR_NOT_ALLOWED);
19+
});
20+
21+
test('recipient can update the recipient', () => {
22+
txOk(contract.updateRecipient(accounts.wallet_1.address), accounts.deployer.address)
23+
24+
const value = rov(contract.getRecipient());
25+
expect(value).toBe(accounts.wallet_1.address);
26+
});
27+
28+
test('updated recipient can re-update the recipient', () => {
29+
txOk(contract.updateRecipient(accounts.wallet_1.address), accounts.deployer.address)
30+
expect(rov(contract.getRecipient())).toBe(accounts.wallet_1.address);
31+
32+
txOk(contract.updateRecipient(accounts.wallet_2.address), accounts.wallet_1.address)
33+
expect(rov(contract.getRecipient())).toBe(accounts.wallet_2.address);
34+
});

0 commit comments

Comments
 (0)