From 61b8f5fc352838866b0fe27b936323de45bf269c Mon Sep 17 00:00:00 2001 From: Eric Mastro Date: Wed, 26 Oct 2022 13:37:30 +1100 Subject: [PATCH] [test] Remove lastSlot return from waitUntilStarted This is a remnant from a staggered ending of slots. All slots will end at the request end time now, and thus this is no longer needed. --- test/Marketplace.test.js | 30 ++++++++++-------------------- test/marketplace.js | 4 +--- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/test/Marketplace.test.js b/test/Marketplace.test.js index 674429d..ff3bfa8 100644 --- a/test/Marketplace.test.js +++ b/test/Marketplace.test.js @@ -178,7 +178,7 @@ describe("Marketplace", function () { }) it("is rejected when request is finished", async function () { - const lastSlot = await waitUntilStarted(marketplace, request, slot, proof) + await waitUntilStarted(marketplace, request, slot, proof) await waitUntilFinished(marketplace, requestId(request)) await expect( marketplace.fillSlot(slot.request, slot.index, proof) @@ -261,7 +261,7 @@ describe("Marketplace", function () { }) it("checks that proof end time is in the past once finished", async function () { - const lastSlot = await waitUntilStarted(marketplace, request, slot, proof) + await waitUntilStarted(marketplace, request, slot, proof) await waitUntilFinished(marketplace, requestId(request)) const now = await currentTime() // in the process of calling currentTime and proofEnd, @@ -368,7 +368,7 @@ describe("Marketplace", function () { }) it("fails to free slot when finished", async function () { - const lastSlot = await waitUntilStarted(marketplace, request, slot, proof) + await waitUntilStarted(marketplace, request, slot, proof) await waitUntilFinished(marketplace, requestId(request)) await expect(marketplace.freeSlot(slotId(slot))).to.be.revertedWith( "Slot not accepting proofs" @@ -405,7 +405,7 @@ describe("Marketplace", function () { }) it("pays the host", async function () { - const lastSlot = await waitUntilStarted(marketplace, request, slot, proof) + await waitUntilStarted(marketplace, request, slot, proof) await waitUntilFinished(marketplace, requestId(request)) const startBalance = await token.balanceOf(host.address) await marketplace.payoutSlot(slot.request, slot.index) @@ -421,7 +421,7 @@ describe("Marketplace", function () { }) it("can only be done once", async function () { - const lastSlot = await waitUntilStarted(marketplace, request, slot, proof) + await waitUntilStarted(marketplace, request, slot, proof) await waitUntilFinished(marketplace, requestId(request)) await marketplace.payoutSlot(slot.request, slot.index) await expect( @@ -430,7 +430,7 @@ describe("Marketplace", function () { }) it("cannot be filled again", async function () { - const lastSlot = await waitUntilStarted(marketplace, request, slot, proof) + await waitUntilStarted(marketplace, request, slot, proof) await waitUntilFinished(marketplace, requestId(request)) await marketplace.payoutSlot(slot.request, slot.index) await expect(marketplace.fillSlot(slot.request, slot.index, proof)).to.be @@ -573,7 +573,7 @@ describe("Marketplace", function () { }) it("state is Finished once slot is paid out", async function () { - const lastSlot = await waitUntilStarted(marketplace, request, slot, proof) + await waitUntilStarted(marketplace, request, slot, proof) await waitUntilFinished(marketplace, requestId(request)) await marketplace.payoutSlot(slot.request, slot.index) await expect(await marketplace.state(slot.request)).to.equal( @@ -661,12 +661,7 @@ describe("Marketplace", function () { }) it("fails when request Finished (isFinished is true)", async function () { - const lastSlot = await waitUntilStarted( - marketplace, - request, - slot, - proof - ) + await waitUntilStarted(marketplace, request, slot, proof) await waitUntilFinished(marketplace, requestId(request)) await expect( marketplace.testAcceptsProofs(slotId(slot)) @@ -674,12 +669,7 @@ describe("Marketplace", function () { }) it("fails when request Finished (state set to Finished)", async function () { - const lastSlot = await waitUntilStarted( - marketplace, - request, - slot, - proof - ) + await waitUntilStarted(marketplace, request, slot, proof) await waitUntilFinished(marketplace, requestId(request)) await marketplace.payoutSlot(slot.request, slot.index) await expect( @@ -734,7 +724,7 @@ describe("Marketplace", function () { it("removes request from list when request finishes", async function () { await marketplace.requestStorage(request) switchAccount(host) - const lastSlot = await waitUntilStarted(marketplace, request, slot, proof) + await waitUntilStarted(marketplace, request, slot, proof) await waitUntilFinished(marketplace, requestId(request)) await marketplace.payoutSlot(slot.request, slot.index) switchAccount(client) diff --git a/test/marketplace.js b/test/marketplace.js index bbcaa72..bbb9801 100644 --- a/test/marketplace.js +++ b/test/marketplace.js @@ -6,11 +6,9 @@ async function waitUntilCancelled(request) { } async function waitUntilStarted(contract, request, slot, proof) { - const lastSlotIdx = request.ask.slots - 1 - for (let i = 0; i <= lastSlotIdx; i++) { + for (let i = 0; i < request.ask.slots; i++) { await contract.fillSlot(slot.request, i, proof) } - return { ...slot, index: lastSlotIdx } } async function waitUntilFinished(contract, requestId) {