From 6c42c0f9a1f26b855b6cfd343e3be1e2cf31d181 Mon Sep 17 00:00:00 2001 From: EDUARDO MELO DE SIQUEIRA Date: Tue, 9 Jul 2024 11:39:30 -0300 Subject: [PATCH] fix: updating test case to cover 100% of tests --- contracts/OriumSftMarketplace.sol | 2 +- test/OriumSftMarketplace.test.ts | 44 +++++++++---------------------- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/contracts/OriumSftMarketplace.sol b/contracts/OriumSftMarketplace.sol index 639f2aa..e454526 100644 --- a/contracts/OriumSftMarketplace.sol +++ b/contracts/OriumSftMarketplace.sol @@ -139,7 +139,7 @@ contract OriumSftMarketplace is Initializable, OwnableUpgradeable, PausableUpgra _offer.tokenId, _offer.tokenAmount ); - }else { + } else { _offer.commitmentId = IERC7589(_rolesRegistryAddress).lockTokens( _offer.lender, _offer.tokenAddress, diff --git a/test/OriumSftMarketplace.test.ts b/test/OriumSftMarketplace.test.ts index 769624c..e9a4cd3 100644 --- a/test/OriumSftMarketplace.test.ts +++ b/test/OriumSftMarketplace.test.ts @@ -208,37 +208,6 @@ describe('OriumSftMarketplace', () => { .to.emit(rolesRegistry, 'TokensLocked') .withArgs(lender.address, 1, await mockERC1155.getAddress(), tokenId, tokenAmount) }) - it('Should create a rental offer with feeAmountPerSecond equal to 0 if offer is private', async function () { - rentalOffer.feeAmountPerSecond = BigInt(0) - rentalOffer.borrower = lender.address - await expect(marketplace.connect(lender).createRentalOffer(rentalOffer)) - .to.emit(marketplace, 'RentalOfferCreated') - .withArgs( - rentalOffer.nonce, - rentalOffer.tokenAddress, - rentalOffer.tokenId, - rentalOffer.tokenAmount, - 1, - rentalOffer.lender, - rentalOffer.borrower, - rentalOffer.feeTokenAddress, - rentalOffer.feeAmountPerSecond, - rentalOffer.deadline, - rentalOffer.minDuration, - rentalOffer.roles, - rentalOffer.rolesData, - ) - .to.emit(mockERC1155, 'TransferSingle') - .withArgs( - await rolesRegistry.getAddress(), - lender.address, - await rolesRegistry.getAddress(), - tokenId, - tokenAmount, - ) - .to.emit(rolesRegistry, 'TokensLocked') - .withArgs(lender.address, 1, await mockERC1155.getAddress(), tokenId, tokenAmount) - }) it('Should use IERC7589Legacy if tokenAddress matches wearableAddress', async () => { await marketplaceRoyalties .connect(operator) @@ -495,6 +464,19 @@ describe('OriumSftMarketplace', () => { .to.emit(marketplace, 'RentalStarted') .withArgs(rentalOffer.lender, rentalOffer.nonce, borrower.address, expirationDate) }) + it('Should create a rental offer with feeAmountPerSecond equal to 0 if offer is private', async function () { + rentalOffer.feeAmountPerSecond = BigInt(0) + rentalOffer.borrower = borrower.address + rentalOffer.nonce = `0x${randomBytes(32).toString('hex')}` + await marketplace.connect(lender).createRentalOffer({ ...rentalOffer, commitmentId: BigInt(0) }) + rentalOffer.commitmentId = BigInt(2) + + const blockTimestamp = (await ethers.provider.getBlock('latest'))?.timestamp + const expirationDate = Number(blockTimestamp) + duration + 1 + await expect(marketplace.connect(borrower).acceptRentalOffer(rentalOffer, duration)) + .to.emit(marketplace, 'RentalStarted') + .withArgs(rentalOffer.lender, rentalOffer.nonce, borrower.address, expirationDate) + }) it('Should accept a private rental offer', async () => { rentalOffer.borrower = borrower.address rentalOffer.nonce = `0x${randomBytes(32).toString('hex')}`