[marketplace] rename state(id) -> requestState(id)
This commit is contained in:
parent
10f88a62a7
commit
de0595edb3
|
@ -105,10 +105,10 @@ contract Marketplace is Collateral, Proofs, StateRetrieval {
|
|||
function freeSlot(SlotId slotId) public {
|
||||
Slot storage slot = _slot(slotId);
|
||||
require(slot.host == msg.sender, "Slot filled by other host");
|
||||
RequestState s = state(slot.requestId);
|
||||
if (s == RequestState.Finished || s == RequestState.Cancelled) {
|
||||
RequestState state = requestState(slot.requestId);
|
||||
if (state == RequestState.Finished || state == RequestState.Cancelled) {
|
||||
payoutSlot(slot.requestId, slotId);
|
||||
} else if (s == RequestState.Failed) {
|
||||
} else if (state == RequestState.Failed) {
|
||||
removeFromMySlots(msg.sender, slotId);
|
||||
} else {
|
||||
_forciblyFreeSlot(slotId);
|
||||
|
@ -179,10 +179,9 @@ contract Marketplace is Collateral, Proofs, StateRetrieval {
|
|||
RequestId requestId,
|
||||
SlotId slotId
|
||||
) private marketplaceInvariant {
|
||||
RequestState requestState = state(requestId);
|
||||
RequestState state = requestState(requestId);
|
||||
require(
|
||||
requestState == RequestState.Finished ||
|
||||
requestState == RequestState.Cancelled,
|
||||
state == RequestState.Finished || state == RequestState.Cancelled,
|
||||
"Contract not ended"
|
||||
);
|
||||
RequestContext storage context = _context(requestId);
|
||||
|
@ -331,7 +330,9 @@ contract Marketplace is Collateral, Proofs, StateRetrieval {
|
|||
return request.ask.duration * request.ask.reward;
|
||||
}
|
||||
|
||||
function state(RequestId requestId) public view returns (RequestState) {
|
||||
function requestState(
|
||||
RequestId requestId
|
||||
) public view returns (RequestState) {
|
||||
RequestContext storage context = _context(requestId);
|
||||
if (
|
||||
context.state == RequestState.New &&
|
||||
|
@ -361,8 +362,8 @@ contract Marketplace is Collateral, Proofs, StateRetrieval {
|
|||
function _requestAcceptsProofs(
|
||||
RequestId requestId
|
||||
) internal view returns (bool) {
|
||||
RequestState s = state(requestId);
|
||||
return s == RequestState.New || s == RequestState.Started;
|
||||
RequestState state = requestState(requestId);
|
||||
return state == RequestState.New || state == RequestState.Started;
|
||||
}
|
||||
|
||||
struct RequestContext {
|
||||
|
|
|
@ -486,7 +486,7 @@ describe("Marketplace", function () {
|
|||
for (let i = 0; i <= lastSlot; i++) {
|
||||
await marketplace.fillSlot(slot.request, i, proof)
|
||||
}
|
||||
await expect(await marketplace.state(slot.request)).to.equal(
|
||||
await expect(await marketplace.requestState(slot.request)).to.equal(
|
||||
RequestState.Started
|
||||
)
|
||||
})
|
||||
|
@ -595,7 +595,7 @@ describe("Marketplace", function () {
|
|||
})
|
||||
|
||||
it("changes state to Cancelled when client withdraws funds", async function () {
|
||||
await expect(await marketplace.state(slot.request)).to.equal(
|
||||
await expect(await marketplace.requestState(slot.request)).to.equal(
|
||||
RequestState.New
|
||||
)
|
||||
})
|
||||
|
@ -604,14 +604,14 @@ describe("Marketplace", function () {
|
|||
await waitUntilCancelled(request)
|
||||
switchAccount(client)
|
||||
await marketplace.withdrawFunds(slot.request)
|
||||
await expect(await marketplace.state(slot.request)).to.equal(
|
||||
await expect(await marketplace.requestState(slot.request)).to.equal(
|
||||
RequestState.Cancelled
|
||||
)
|
||||
})
|
||||
|
||||
it("changes state to Started once all slots are filled", async function () {
|
||||
await waitUntilStarted(marketplace, request, proof)
|
||||
await expect(await marketplace.state(slot.request)).to.equal(
|
||||
await expect(await marketplace.requestState(slot.request)).to.equal(
|
||||
RequestState.Started
|
||||
)
|
||||
})
|
||||
|
@ -619,7 +619,7 @@ describe("Marketplace", function () {
|
|||
it("state is Failed once too many slots are freed", async function () {
|
||||
await waitUntilStarted(marketplace, request, proof)
|
||||
await waitUntilFailed(marketplace, request)
|
||||
await expect(await marketplace.state(slot.request)).to.equal(
|
||||
await expect(await marketplace.requestState(slot.request)).to.equal(
|
||||
RequestState.Failed
|
||||
)
|
||||
})
|
||||
|
@ -628,7 +628,7 @@ describe("Marketplace", function () {
|
|||
await waitUntilStarted(marketplace, request, proof)
|
||||
await waitUntilFinished(marketplace, requestId(request))
|
||||
await marketplace.freeSlot(slotId(slot))
|
||||
await expect(await marketplace.state(slot.request)).to.equal(
|
||||
await expect(await marketplace.requestState(slot.request)).to.equal(
|
||||
RequestState.Finished
|
||||
)
|
||||
})
|
||||
|
@ -641,14 +641,14 @@ describe("Marketplace", function () {
|
|||
let id = slotId(slot)
|
||||
await marketplace.forciblyFreeSlot(id)
|
||||
}
|
||||
await expect(await marketplace.state(slot.request)).to.equal(
|
||||
await expect(await marketplace.requestState(slot.request)).to.equal(
|
||||
RequestState.New
|
||||
)
|
||||
})
|
||||
|
||||
it("changes state to Cancelled once request is cancelled", async function () {
|
||||
await waitUntilCancelled(request)
|
||||
await expect(await marketplace.state(slot.request)).to.equal(
|
||||
await expect(await marketplace.requestState(slot.request)).to.equal(
|
||||
RequestState.Cancelled
|
||||
)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue