mirror of
https://github.com/codex-storage/codex-contracts-eth.git
synced 2025-02-18 06:16:33 +00:00
[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:
parent
3fbc851a8d
commit
a96333ce5f
@ -43,11 +43,7 @@ contract Marketplace is Collateral, Proofs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isActive(bytes32 slot) private view returns (bool) {
|
function isActive(bytes32 slot) private view returns (bool) {
|
||||||
RequestState s = state(requestForSlot[SlotId.wrap(slot)]);
|
return state(requestForSlot[SlotId.wrap(slot)]) != RequestState.Failed;
|
||||||
return
|
|
||||||
s == RequestState.New ||
|
|
||||||
s == RequestState.Started ||
|
|
||||||
s == RequestState.Finished;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mySlots() public view returns (SlotId[] memory) {
|
function mySlots() public view returns (SlotId[] memory) {
|
||||||
|
@ -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)
|
await marketplace.fillSlot(slot.request, slot.index, proof)
|
||||||
let slot1 = { ...slot, index: slot.index + 1 }
|
let slot1 = { ...slot, index: slot.index + 1 }
|
||||||
await marketplace.fillSlot(slot.request, slot1.index, proof)
|
await marketplace.fillSlot(slot.request, slot1.index, proof)
|
||||||
@ -766,12 +766,15 @@ describe("Marketplace", function () {
|
|||||||
expect(await marketplace.mySlots()).to.have.members([slotId(slot1)])
|
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)
|
await marketplace.fillSlot(slot.request, slot.index, proof)
|
||||||
let slot1 = { ...slot, index: slot.index + 1 }
|
let slot1 = { ...slot, index: slot.index + 1 }
|
||||||
await marketplace.fillSlot(slot.request, slot1.index, proof)
|
await marketplace.fillSlot(slot.request, slot1.index, proof)
|
||||||
await waitUntilCancelled(request)
|
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 () {
|
it("removes active slots for all hosts in a request when it fails", async function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user