From a41fc47ad23d77c92e0d5f1c201ff4968fc7e8d1 Mon Sep 17 00:00:00 2001 From: EDUARDO MELO DE SIQUEIRA Date: Fri, 12 Jul 2024 17:55:41 -0300 Subject: [PATCH] fix: updating tests to coverage --- test/OriumSftMarketplace.test.ts | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/test/OriumSftMarketplace.test.ts b/test/OriumSftMarketplace.test.ts index c2b035e..7466d70 100644 --- a/test/OriumSftMarketplace.test.ts +++ b/test/OriumSftMarketplace.test.ts @@ -1393,6 +1393,65 @@ describe('OriumSftMarketplace', () => { .batchRevokeRole([1], [UNIQUE_ROLE], [borrower.address], [await wearableToken.getAddress()]), ).to.be.revertedWith('OriumSftMarketplace: role is not revocable Legacy') }) + it('Should NOT batch revoke role if if role is expired', async () => { + await rolesRegistry + .connect(lender) + .grantRole( + 1, + UNIQUE_ROLE, + borrower.address, + Number((await ethers.provider.getBlock('latest'))?.timestamp) + ONE_DAY, + false, + EMPTY_BYTES, + ) + await rolesRegistry + .connect(borrower) + .setRoleApprovalForAll(await mockERC1155.getAddress(), await marketplace.getAddress(), true) + await time.increase(ONE_DAY) + await expect( + marketplace + .connect(lender) + .batchRevokeRole([1], [UNIQUE_ROLE], [borrower.address], [await mockERC1155.getAddress()]), + ).to.be.revertedWith('OriumSftMarketplace: role is expired') + }) + it('Should NOT batch LEGACY revoke role if role is expired', async () => { + await marketplaceRoyalties + .connect(operator) + .setRolesRegistry(await wearableToken.getAddress(), await SftRolesRegistrySingleRoleLegacy.getAddress()) + await wearableToken.setApprovalForAll(await SftRolesRegistrySingleRoleLegacy.getAddress(), true) + + commitAndGrantRoleParams[0].tokenAddress = await wearableToken.getAddress() + + await SftRolesRegistrySingleRoleLegacy.connect(lender).setRoleApprovalForAll( + await wearableToken.getAddress(), + await marketplace.getAddress(), + true, + ) + await wearableToken + .connect(lender) + .setApprovalForAll(await SftRolesRegistrySingleRoleLegacy.getAddress(), true) + expect(marketplace.connect(lender).batchCommitTokensAndGrantRole(commitAndGrantRoleParams)) + + await SftRolesRegistrySingleRoleLegacy.connect(lender).grantRole( + 1, + UNIQUE_ROLE, + borrower.address, + Number((await ethers.provider.getBlock('latest'))?.timestamp) + ONE_DAY, + false, + EMPTY_BYTES, + ) + await SftRolesRegistrySingleRoleLegacy.connect(borrower).setRoleApprovalForAll( + await wearableToken.getAddress(), + await marketplace.getAddress(), + true, + ) + await time.increase(ONE_DAY) + await expect( + marketplace + .connect(lender) + .batchRevokeRole([1], [UNIQUE_ROLE], [borrower.address], [await wearableToken.getAddress()]), + ).to.be.revertedWith('OriumSftMarketplace: role is expired') + }) }) }) })