@@ -8,7 +8,7 @@ const { describe } = require('yargs')
8
8
const server = "http://127.0.0.1"
9
9
const port = 8080
10
10
11
- var adminAccount , receiverAccount , token , clientV2 , appId
11
+ var adminAccount , receiverAccount , token , clientV2 , appId , localState
12
12
13
13
beforeEach ( async ( ) => {
14
14
await privateTestNetSetup ( appId )
@@ -23,17 +23,23 @@ beforeEach(async () => {
23
23
await util . optInApp ( clientV2 , receiverAccount , appId )
24
24
} )
25
25
26
- test ( 'contract admin role can be granted by contract admin' , async ( ) => {
26
+ async function grantRoles ( roleId , from = adminAccount , target = receiverAccount ) {
27
27
appArgs = [
28
28
EncodeBytes ( "grantRoles" ) ,
29
- EncodeUint ( '8' )
29
+ EncodeUint ( roleId )
30
30
]
31
- await util . appCall ( clientV2 , adminAccount , appId , appArgs , [ receiverAccount . addr ] )
31
+ await util . appCall ( clientV2 , from , appId , appArgs , [ target . addr ] )
32
+ }
33
+
34
+ test ( 'contract admin role can be granted by contract admin' , async ( ) => {
35
+ await grantRoles ( 8 , adminAccount , receiverAccount )
32
36
33
37
localState = await util . readLocalState ( clientV2 , receiverAccount , appId )
34
38
expect ( localState [ "roles" ] [ "ui" ] ) . toEqual ( 8 )
35
39
36
- await util . appCall ( clientV2 , receiverAccount , appId , appArgs , [ receiverAccount . addr ] )
40
+ await grantRoles ( 15 , receiverAccount , receiverAccount )
41
+ localState = await util . readLocalState ( clientV2 , receiverAccount , appId )
42
+ expect ( localState [ "roles" ] [ "ui" ] ) . toEqual ( 15 )
37
43
} )
38
44
39
45
test ( 'contract admin role can be revoked by contract admin' , async ( ) => {
0 commit comments