[marketplace] mySlots() returns slots of cancelled request

Reasoning: the node will want to call payoutSlot() for
cancelled requests, at which point it will be removed
from the list.
This commit is contained in:
Mark Spanbroek 2022-11-23 14:18:42 +01:00 committed by markspanbroek
parent 3fbc851a8d
commit a96333ce5f
2 changed files with 7 additions and 8 deletions

View File

@ -43,11 +43,7 @@ contract Marketplace is Collateral, Proofs {
}
function isActive(bytes32 slot) private view returns (bool) {
RequestState s = state(requestForSlot[SlotId.wrap(slot)]);
return
s == RequestState.New ||
s == RequestState.Started ||
s == RequestState.Finished;
return state(requestForSlot[SlotId.wrap(slot)]) != RequestState.Failed;
}
function mySlots() public view returns (SlotId[] memory) {

View File

@ -758,7 +758,7 @@ describe("Marketplace", function () {
])
})
it("removes request from list when slot is freed", async function () {
it("removes slot from list when slot is freed", async function () {
await marketplace.fillSlot(slot.request, slot.index, proof)
let slot1 = { ...slot, index: slot.index + 1 }
await marketplace.fillSlot(slot.request, slot1.index, proof)
@ -766,12 +766,15 @@ describe("Marketplace", function () {
expect(await marketplace.mySlots()).to.have.members([slotId(slot1)])
})
it("returns no slots when cancelled", async function () {
it("keeps slots when cancelled", async function () {
await marketplace.fillSlot(slot.request, slot.index, proof)
let slot1 = { ...slot, index: slot.index + 1 }
await marketplace.fillSlot(slot.request, slot1.index, proof)
await waitUntilCancelled(request)
expect(await marketplace.mySlots()).to.have.members([])
expect(await marketplace.mySlots()).to.have.members([
slotId(slot),
slotId(slot1),
])
})
it("removes active slots for all hosts in a request when it fails", async function () {