[marketplace] add more tests

Add missing tests for `isSlotCancelled`.

Add test ensuring that proofs cannot be marked as missed when a contract is cancelled.
This commit is contained in:
Eric Mastro 2022-08-16 13:19:51 +10:00 committed by Eric Mastro
parent 34553ad7d9
commit f16b9b07ae
2 changed files with 23 additions and 0 deletions

View File

@ -357,6 +357,20 @@ describe("Marketplace", function () {
await expect(await marketplace.isCancelled(slot.request)).to.equal(true)
})
it("isSlotCancelled fails when slot is empty", async function () {
await expect(
marketplace.isSlotCancelled(slotId(slot))
).to.be.revertedWith("Slot empty")
})
it("isSlotCancelled is true once request is cancelled", async function () {
await marketplace.fillSlot(slot.request, slot.index, proof)
await waitUntilExpired(request.expiry)
await expect(await marketplace.isSlotCancelled(slotId(slot))).to.equal(
true
)
})
it("state is Cancelled when client withdraws funds", async function () {
await expect(await marketplace.state(slot.request)).to.equal(
RequestState.New

View File

@ -111,6 +111,15 @@ describe("Storage", function () {
const expectedBalance = (collateralAmount * (100 - slashPercentage)) / 100
expect(await storage.balanceOf(host.address)).to.equal(expectedBalance)
})
it("fails to mark proof as missing when cancelled", async function () {
await storage.fillSlot(slot.request, slot.index, proof)
await advanceTimeTo(request.expiry + 1)
let missedPeriod = periodOf(await currentTime())
await expect(
storage.markProofAsMissing(slotId(slot), missedPeriod)
).to.be.revertedWith("Request was cancelled")
})
})
})