Skip to content

Commit

Permalink
ON-480: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lima committed Sep 29, 2023
1 parent 0b3ae4f commit ae6d21a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/OriumMarketplace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,30 @@ describe('OriumMarketplace', () => {
})
})

describe.only('Cancel Rental Offer', async () => {
describe('Cancel Rental Offer', async () => {
beforeEach(async () => {
await marketplace.connect(lender).createRentalOffer(rentalOffer)
})
it('Should cancel a rental offer', async () => {
await expect(marketplace.connect(lender).cancelRentalOffer(rentalOffer))
await expect(marketplace.connect(lender).cancelRentalOffer(rentalOffer.nonce))
.to.emit(marketplace, 'RentalOfferCancelled')
.withArgs(rentalOffer.nonce, lender.address)
})
it('Should NOT cancel a rental offer if nonce not used yet by caller', async () => {
await expect(marketplace.connect(notOperator).cancelRentalOffer(rentalOffer.nonce)).to.be.revertedWith(
'OriumMarketplace: Nonce expired or not used yet',
)
})
it("Should NOT cancel a rental offer after deadline's expiration", async () => {
// move foward in time to expire the offer
const blockTimestamp = (await ethers.provider.getBlock('latest')).timestamp
const timeToMove = rentalOffer.deadline - blockTimestamp + 1
await ethers.provider.send('evm_increaseTime', [timeToMove])

await expect(marketplace.connect(lender).cancelRentalOffer(rentalOffer.nonce)).to.be.revertedWith(
'OriumMarketplace: Nonce expired or not used yet',
)
})
})

describe('Fees', async function () {
Expand Down

0 comments on commit ae6d21a

Please sign in to comment.