From 49bd7bd42779f6ca4615b9b3ee1c0c73c3ba7d29 Mon Sep 17 00:00:00 2001 From: Daniel Lima Date: Mon, 18 Sep 2023 18:27:06 -0300 Subject: [PATCH] ON-476: Add more tests --- test/ERC7432.spec.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/ERC7432.spec.ts b/test/ERC7432.spec.ts index 47b6cf1..a191677 100644 --- a/test/ERC7432.spec.ts +++ b/test/ERC7432.spec.ts @@ -168,6 +168,7 @@ describe('ERC7432', () => { await expect(ERC7432.connect(grantor).revokeRole(PROPERTY_MANAGER, AddressZero, tokenId, grantor.address)) .to.emit(ERC7432, 'RoleRevoked') .withArgs(PROPERTY_MANAGER, AddressZero, tokenId, grantor.address, grantor.address) + expect(await ERC7432.hasRole(PROPERTY_MANAGER, AddressZero, tokenId, grantor.address, grantor.address)).to.be.equal(false) }) it('should NOT revoke role if role is not revocable', async () => { await ERC7432.connect(grantor).grantRole( @@ -469,6 +470,22 @@ describe('ERC7432', () => { ), ).to.be.revertedWith('ERC7432: sender must be approved') }) + it('should revoke role from if operator is approved by grantee', async () => { + await ERC7432.connect(userOne).approveRole(AddressZero, tokenId, operator.address, true) + expect(await ERC7432.hasRole(PROPERTY_MANAGER, AddressZero, tokenId, grantor.address, userOne.address)).to.be.equal(true) + await expect( + ERC7432.connect(operator).revokeRoleFrom( + PROPERTY_MANAGER, + AddressZero, + tokenId, + grantor.address, + userOne.address, + ), + ) + .to.emit(ERC7432, 'RoleRevoked') + .withArgs(PROPERTY_MANAGER, AddressZero, tokenId, grantor.address, userOne.address) + expect(await ERC7432.hasRole(PROPERTY_MANAGER, AddressZero, tokenId, grantor.address, userOne.address)).to.be.equal(false) + }) }) }) }