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