Skip to content

Commit

Permalink
fix: updating test case to cover 100% of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EDUARDO MELO DE SIQUEIRA authored and EDUARDO MELO DE SIQUEIRA committed Jul 9, 2024
1 parent e9699d2 commit 6c42c0f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
2 changes: 1 addition & 1 deletion contracts/OriumSftMarketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
44 changes: 13 additions & 31 deletions test/OriumSftMarketplace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')}`
Expand Down

0 comments on commit 6c42c0f

Please sign in to comment.