From 476a624e8934a3c2fd66ff9f789707f0053c9c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Guti=C3=A9rrez?= Date: Thu, 26 Sep 2019 14:59:05 +0200 Subject: [PATCH] Add integration test about adding permissions on DIDRegistry. --- integration/ocean/AssetOwners.test.ts | 10 ++++++++++ src/keeper/contracts/DIDRegistry.ts | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/integration/ocean/AssetOwners.test.ts b/integration/ocean/AssetOwners.test.ts index dbdd624..1eea73a 100644 --- a/integration/ocean/AssetOwners.test.ts +++ b/integration/ocean/AssetOwners.test.ts @@ -37,6 +37,16 @@ describe('Asset Owners', () => { assert.isTrue(isProvider) }) + it('should be added correctly a permission on an asset', async () => { + const ddo = await ocean.assets.create(metadata as any, account1) + + assert.isFalse(await ocean.keeper.didRegistry.getPermission(ddo.id, account2.getId())) + + await ocean.keeper.didRegistry.grantPermission(ddo.id, account2.getId(), account1.getId()) + + assert.isTrue(await ocean.keeper.didRegistry.getPermission(ddo.id, account2.getId())) + }) + it('should get the assets owned by a user', async () => { const { length: initialLength } = await ocean.assets.ownerAssets(account2.getId()) diff --git a/src/keeper/contracts/DIDRegistry.ts b/src/keeper/contracts/DIDRegistry.ts index 90e6883..13f29e1 100644 --- a/src/keeper/contracts/DIDRegistry.ts +++ b/src/keeper/contracts/DIDRegistry.ts @@ -50,7 +50,7 @@ export default class DIDRegistry extends ContractBase { } public async grantPermission(did: string, grantee: string, ownerAddress: string) { - return this.send('grantPermission', ownerAddress, [zeroX(did), zeroX(grantee)]) + return this.send('grantPermission', ownerAddress, [didZeroX(did), zeroX(grantee)]) } public async revokePermission(did: string, grantee: string, ownerAddress: string) {