Skip to content

Commit

Permalink
ON-813: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lima committed Apr 19, 2024
1 parent bef46f8 commit ab03256
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions contracts/libraries/LibNftRentalMarketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ library LibNftRentalMarketplace {
*/
function _transferAmount(address _tokenAddress, address _from, address _to, uint256 _amount) internal {
if (_amount == 0) return;
require(IERC20(_tokenAddress).transferFrom(_from, _to, _amount), 'OriumNftMarketplace: Transfer failed');
require(IERC20(_tokenAddress).transferFrom(_from, _to, _amount), 'NftRentalMarketplace: Transfer failed');
}

function validateAcceptRentalOfferParams(
Expand All @@ -155,19 +155,19 @@ library LibNftRentalMarketplace {
uint256 _nonceDeadline,
uint64 _expirationDate
) external view {
require(_isCreated, 'OriumNftMarketplace: Offer not created');
require(_isCreated, 'NftRentalMarketplace: Offer not created');
require(
_previousRentalExpirationDate <= block.timestamp,
'OriumNftMarketplace: This offer has an ongoing rental'
'NftRentalMarketplace: This offer has an ongoing rental'
);
require(_duration >= _minDuration, 'OriumNftMarketplace: Duration is less than the offer minimum duration');
require(_duration >= _minDuration, 'NftRentalMarketplace: Duration is less than the offer minimum duration');
require(
_nonceDeadline > _expirationDate,
'OriumNftMarketplace: expiration date is greater than offer deadline'
'NftRentalMarketplace: expiration date is greater than offer deadline'
);
require(
address(0) == _borrower || msg.sender == _borrower,
'OriumNftMarketplace: Sender is not allowed to rent this NFT'
'NftRentalMarketplace: Sender is not allowed to rent this NFT'
);
}

Expand Down
18 changes: 9 additions & 9 deletions test/NftRentalMarketplace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ describe('NftRentalMarketplace', () => {
await marketplace.connect(lender).createRentalOffer(rentalOffer)
await expect(
marketplace.connect(borrower).acceptRentalOffer(rentalOffer, duration / 2),
).to.be.revertedWith('OriumNftMarketplace: Duration is less than the offer minimum duration')
).to.be.revertedWith('NftRentalMarketplace: Duration is less than the offer minimum duration')
})
it('Should NOT accept a rental offer if contract is paused', async () => {
await marketplace.connect(operator).pause()
Expand All @@ -384,7 +384,7 @@ describe('NftRentalMarketplace', () => {
await mockERC20.mint(notOperator.address, totalFeeAmount.toString())
await expect(
marketplace.connect(notOperator).acceptRentalOffer(rentalOffer, duration),
).to.be.revertedWith('OriumNftMarketplace: Sender is not allowed to rent this NFT')
).to.be.revertedWith('NftRentalMarketplace: Sender is not allowed to rent this NFT')
})
it('Should NOT accept a rental offer if offer is expired', async () => {
// move foward in time to expire the offer
Expand All @@ -393,20 +393,20 @@ describe('NftRentalMarketplace', () => {
await ethers.provider.send('evm_increaseTime', [timeToMove])

await expect(marketplace.connect(borrower).acceptRentalOffer(rentalOffer, duration)).to.be.revertedWith(
'OriumNftMarketplace: expiration date is greater than offer deadline',
'NftRentalMarketplace: expiration date is greater than offer deadline',
)
})
it('Should NOT accept a rental offer if offer is not created', async () => {
rentalOffer.nonce = `0x${randomBytes(32).toString('hex')}`
await expect(marketplace.connect(borrower).acceptRentalOffer(rentalOffer, duration)).to.be.revertedWith(
'OriumNftMarketplace: Offer not created',
'NftRentalMarketplace: Offer not created',
)
})
it('Should NOT accept a rental offer if expiration date is higher than offer deadline', async () => {
const maxDuration = rentalOffer.deadline - Number(await time.latest()) + 1
await expect(
marketplace.connect(borrower).acceptRentalOffer(rentalOffer, maxDuration),
).to.be.revertedWith('OriumNftMarketplace: expiration date is greater than offer deadline')
).to.be.revertedWith('NftRentalMarketplace: expiration date is greater than offer deadline')
})
describe('Fees', async function () {
const feeAmountPerSecond = toWei('1')
Expand Down Expand Up @@ -451,25 +451,25 @@ describe('NftRentalMarketplace', () => {
it('Should NOT accept a rental offer if marketplace fee transfer fails', async () => {
await mockERC20.transferReverts(true, 0)
await expect(marketplace.connect(borrower).acceptRentalOffer(rentalOffer, duration)).to.be.revertedWith(
'OriumNftMarketplace: Transfer failed',
'NftRentalMarketplace: Transfer failed',
)
})
it('Should NOT accept a rental offer if royalty fee transfer fails', async () => {
await mockERC20.transferReverts(true, 1)
await expect(marketplace.connect(borrower).acceptRentalOffer(rentalOffer, duration)).to.be.revertedWith(
'OriumNftMarketplace: Transfer failed',
'NftRentalMarketplace: Transfer failed',
)
})
it('Should NOT accept a rental offer if lender fee transfer fails', async () => {
await mockERC20.transferReverts(true, 2)
await expect(marketplace.connect(borrower).acceptRentalOffer(rentalOffer, duration)).to.be.revertedWith(
'OriumNftMarketplace: Transfer failed',
'NftRentalMarketplace: Transfer failed',
)
})
it('Should NOT accept a rental offer twice', async () => {
await marketplace.connect(borrower).acceptRentalOffer(rentalOffer, duration)
await expect(marketplace.connect(borrower).acceptRentalOffer(rentalOffer, duration)).to.be.revertedWith(
'OriumNftMarketplace: This offer has an ongoing rental',
'NftRentalMarketplace: This offer has an ongoing rental',
)
})
})
Expand Down

0 comments on commit ab03256

Please sign in to comment.