From b16defb641f9d01fefd99072ca32ee91290da57f Mon Sep 17 00:00:00 2001 From: Giorgi Lagidze Date: Tue, 24 Sep 2024 17:55:30 +0400 Subject: [PATCH] separate tests --- .../core/permission/permission-manager.ts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/contracts/test/core/permission/permission-manager.ts b/packages/contracts/test/core/permission/permission-manager.ts index 0df530849..11358c183 100644 --- a/packages/contracts/test/core/permission/permission-manager.ts +++ b/packages/contracts/test/core/permission/permission-manager.ts @@ -947,7 +947,7 @@ describe.only('Core: PermissionManager', function () { await pm.connect(alice).grant(someWhere, someWhere, somePermissionId); }); - it('should still keep the other flag for delegatee if only one flag is used/depleted', async () => { + it('should still keep `REVOKE_OWNER_FLAG` for delegatee if only `GRANT_OWNER_FLAG` is used/depleted', async () => { let owner = signers[3]; let alice = signers[4]; @@ -1578,6 +1578,35 @@ describe.only('Core: PermissionManager', function () { .withArgs(someWhere, otherSigner.address, somePermissionId); }); + it('should still keep `GRANT_OWNER_FLAG` for delegatee if only `REVOKE_OWNER_FLAG` is used/depleted', async () => { + let owner = signers[3]; + let alice = signers[4]; + + await pm.createPermission(someWhere, somePermissionId, owner.address, []); + + // Alice became a delegate of `GRANT_OWNER_FLAG` on this permission + await pm + .connect(owner) + .delegatePermission( + someWhere, + somePermissionId, + alice.address, + FULL_OWNER_FLAG + ); + + await pm.connect(alice).revoke(someWhere, someWhere, somePermissionId); + + let currentFlags = await pm.getFlags( + someWhere, + somePermissionId, + alice.address + ); + expect(currentFlags).to.deep.equal([0, GRANT_OWNER_FLAG]); + await expect( + pm.connect(alice).grant(someWhere, someWhere, somePermissionId) + ).to.not.be.reverted; + }); + it('should revert if undelegate got called before revoke got called by the delegatee', async () => { await pm .connect(ownerSigner)