Skip to content

Commit

Permalink
update var name
Browse files Browse the repository at this point in the history
  • Loading branch information
jia57b committed Dec 3, 2024
1 parent c13f694 commit 402c9f2
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions test/hardhat/e2e/permission/permission.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ describe("Permission", function () {
const tokenId = await mintNFT(signers[0].address);
const connectedRegistry = this.ipAssetRegistry.connect(signers[0]);
const func = hre.ethers.encodeBytes32String("attachLicenseTerms").slice(0, 10);
console.log(func);
const ALLOW_permission = 1;
const DENY_permission = 2;
let permissionAfter: number;
let result: any;

const ipId = await expect(
connectedRegistry.register(this.chainId, MockERC721, tokenId)
Expand All @@ -30,27 +31,24 @@ describe("Permission", function () {
const connecedAccessController = this.accessController.connect(signers[0]);

const permissionBefore = await connecedAccessController.getPermission(ipId, signers[0].address, LicensingModule, func);
console.log("permissionBefore:", permissionBefore);
expect(permissionBefore).to.equal(0);

// add ALLOW permission
const result1 = await connecedAccessController.setPermission(ipId, signers[0].address, LicensingModule, func, ALLOW_permission);
expect(result1.hash).to.not.be.empty.and.to.be.a("HexString");
await result1.wait();
result = await connecedAccessController.setPermission(ipId, signers[0].address, LicensingModule, func, ALLOW_permission);
expect(result.hash).to.not.be.empty.and.to.be.a("HexString");
await result.wait();

// get the permission
const permissionAfter1 = await connecedAccessController.getPermission(ipId, signers[0].address, LicensingModule, func);
console.log("permissionAfter:", permissionAfter1);
expect(permissionAfter1).to.equal(ALLOW_permission);
// check the permission
permissionAfter = await connecedAccessController.getPermission(ipId, signers[0].address, LicensingModule, func);
expect(permissionAfter).to.equal(ALLOW_permission);

// Change to DENY permission
const result2 = await connecedAccessController.setPermission(ipId, signers[0].address, LicensingModule, func, DENY_permission);
expect(result2.hash).to.not.be.empty.and.to.be.a("HexString");
await result2.wait();

// get the permission
const permissionAfter2 = await connecedAccessController.getPermission(ipId, signers[0].address, LicensingModule, func);
console.log("permissionAfter:", permissionAfter2);
expect(permissionAfter2).to.equal(DENY_permission);
result = await connecedAccessController.setPermission(ipId, signers[0].address, LicensingModule, func, DENY_permission);
expect(result.hash).to.not.be.empty.and.to.be.a("HexString");
await result.wait();

// check the permission
permissionAfter = await connecedAccessController.getPermission(ipId, signers[0].address, LicensingModule, func);
expect(permissionAfter).to.equal(DENY_permission);
});
});

0 comments on commit 402c9f2

Please sign in to comment.