[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.
This commit is contained in:
Eric Mastro 2022-10-26 13:37:30 +11:00
parent 4a470c7dc7
commit 61b8f5fc35
No known key found for this signature in database
GPG Key ID: 141E3048D95A4E63
2 changed files with 11 additions and 23 deletions

View File

@ -178,7 +178,7 @@ describe("Marketplace", function () {
}) })
it("is rejected when request is finished", async 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 waitUntilFinished(marketplace, requestId(request))
await expect( await expect(
marketplace.fillSlot(slot.request, slot.index, proof) 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 () { 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)) await waitUntilFinished(marketplace, requestId(request))
const now = await currentTime() const now = await currentTime()
// in the process of calling currentTime and proofEnd, // in the process of calling currentTime and proofEnd,
@ -368,7 +368,7 @@ describe("Marketplace", function () {
}) })
it("fails to free slot when finished", async 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 waitUntilFinished(marketplace, requestId(request))
await expect(marketplace.freeSlot(slotId(slot))).to.be.revertedWith( await expect(marketplace.freeSlot(slotId(slot))).to.be.revertedWith(
"Slot not accepting proofs" "Slot not accepting proofs"
@ -405,7 +405,7 @@ describe("Marketplace", function () {
}) })
it("pays the host", async 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)) await waitUntilFinished(marketplace, requestId(request))
const startBalance = await token.balanceOf(host.address) const startBalance = await token.balanceOf(host.address)
await marketplace.payoutSlot(slot.request, slot.index) await marketplace.payoutSlot(slot.request, slot.index)
@ -421,7 +421,7 @@ describe("Marketplace", function () {
}) })
it("can only be done once", async 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 waitUntilFinished(marketplace, requestId(request))
await marketplace.payoutSlot(slot.request, slot.index) await marketplace.payoutSlot(slot.request, slot.index)
await expect( await expect(
@ -430,7 +430,7 @@ describe("Marketplace", function () {
}) })
it("cannot be filled again", async 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 waitUntilFinished(marketplace, requestId(request))
await marketplace.payoutSlot(slot.request, slot.index) await marketplace.payoutSlot(slot.request, slot.index)
await expect(marketplace.fillSlot(slot.request, slot.index, proof)).to.be 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 () { 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 waitUntilFinished(marketplace, requestId(request))
await marketplace.payoutSlot(slot.request, slot.index) await marketplace.payoutSlot(slot.request, slot.index)
await expect(await marketplace.state(slot.request)).to.equal( 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 () { it("fails when request Finished (isFinished is true)", async function () {
const lastSlot = await waitUntilStarted( await waitUntilStarted(marketplace, request, slot, proof)
marketplace,
request,
slot,
proof
)
await waitUntilFinished(marketplace, requestId(request)) await waitUntilFinished(marketplace, requestId(request))
await expect( await expect(
marketplace.testAcceptsProofs(slotId(slot)) marketplace.testAcceptsProofs(slotId(slot))
@ -674,12 +669,7 @@ describe("Marketplace", function () {
}) })
it("fails when request Finished (state set to Finished)", async function () { it("fails when request Finished (state set to Finished)", async function () {
const lastSlot = await waitUntilStarted( await waitUntilStarted(marketplace, request, slot, proof)
marketplace,
request,
slot,
proof
)
await waitUntilFinished(marketplace, requestId(request)) await waitUntilFinished(marketplace, requestId(request))
await marketplace.payoutSlot(slot.request, slot.index) await marketplace.payoutSlot(slot.request, slot.index)
await expect( await expect(
@ -734,7 +724,7 @@ describe("Marketplace", function () {
it("removes request from list when request finishes", async function () { it("removes request from list when request finishes", async function () {
await marketplace.requestStorage(request) await marketplace.requestStorage(request)
switchAccount(host) switchAccount(host)
const lastSlot = await waitUntilStarted(marketplace, request, slot, proof) await waitUntilStarted(marketplace, request, slot, proof)
await waitUntilFinished(marketplace, requestId(request)) await waitUntilFinished(marketplace, requestId(request))
await marketplace.payoutSlot(slot.request, slot.index) await marketplace.payoutSlot(slot.request, slot.index)
switchAccount(client) switchAccount(client)

View File

@ -6,11 +6,9 @@ async function waitUntilCancelled(request) {
} }
async function waitUntilStarted(contract, request, slot, proof) { async function waitUntilStarted(contract, request, slot, proof) {
const lastSlotIdx = request.ask.slots - 1 for (let i = 0; i < request.ask.slots; i++) {
for (let i = 0; i <= lastSlotIdx; i++) {
await contract.fillSlot(slot.request, i, proof) await contract.fillSlot(slot.request, i, proof)
} }
return { ...slot, index: lastSlotIdx }
} }
async function waitUntilFinished(contract, requestId) { async function waitUntilFinished(contract, requestId) {