[sales] make slotIndex non-optional
This commit is contained in:
parent
8a8e7aed70
commit
b017359d13
|
@ -75,8 +75,8 @@ proc handleRequest(sales: Sales,
|
|||
let agent = newSalesAgent(
|
||||
sales,
|
||||
requestId,
|
||||
slotIndex,
|
||||
availability,
|
||||
some slotIndex,
|
||||
none StorageRequest
|
||||
)
|
||||
|
||||
|
@ -103,8 +103,8 @@ proc load*(sales: Sales) {.async.} =
|
|||
let agent = newSalesAgent(
|
||||
sales,
|
||||
request.id,
|
||||
slotIndex,
|
||||
availability,
|
||||
some slotIndex,
|
||||
some request)
|
||||
|
||||
await agent.start(request.ask.slots)
|
||||
|
|
|
@ -6,8 +6,8 @@ import ../contracts/requests
|
|||
|
||||
proc newSalesAgent*(sales: Sales,
|
||||
requestId: RequestId,
|
||||
slotIndex: UInt256,
|
||||
availability: ?Availability,
|
||||
slotIndex: ?UInt256,
|
||||
request: ?StorageRequest): SalesAgent =
|
||||
SalesAgent(
|
||||
sales: sales,
|
||||
|
|
|
@ -32,7 +32,7 @@ type
|
|||
ask*: StorageAsk
|
||||
availability*: ?Availability # TODO: when availability persistence is added, change this to not optional
|
||||
request*: ?StorageRequest
|
||||
slotIndex*: ?UInt256 # TODO: disallow optional; SalesAgents should always have a slotIndex
|
||||
slotIndex*: UInt256
|
||||
failed*: market.Subscription
|
||||
fulfilled*: market.Subscription
|
||||
slotFilled*: market.Subscription
|
||||
|
|
|
@ -264,8 +264,8 @@ suite "Sales state machine":
|
|||
|
||||
proc newSalesAgent(slotIdx: UInt256 = 0.u256): SalesAgent =
|
||||
let agent = sales.newSalesAgent(request.id,
|
||||
slotIdx,
|
||||
some availability,
|
||||
some slotIdx,
|
||||
some request)
|
||||
return agent
|
||||
|
||||
|
@ -455,7 +455,7 @@ suite "Sales state machine":
|
|||
market.requested.add request
|
||||
market.state[request.id] = RequestState.New
|
||||
await agent.switchAsync(SaleDownloading())
|
||||
market.fillSlot(request.id, !agent.slotIndex, proof, Address.example)
|
||||
market.fillSlot(request.id, agent.slotIndex, proof, Address.example)
|
||||
await sleepAsync chronos.seconds(2)
|
||||
|
||||
let state = (agent.state as SaleErrored)
|
||||
|
@ -472,7 +472,7 @@ suite "Sales state machine":
|
|||
market.requested.add request
|
||||
market.state[request.id] = RequestState.New
|
||||
await agent.switchAsync(SaleProving())
|
||||
market.fillSlot(request.id, !agent.slotIndex, proof, Address.example)
|
||||
market.fillSlot(request.id, agent.slotIndex, proof, Address.example)
|
||||
await sleepAsync chronos.seconds(2)
|
||||
|
||||
let state = (agent.state as SaleErrored)
|
||||
|
@ -488,7 +488,7 @@ suite "Sales state machine":
|
|||
await agent.start(request.ask.slots)
|
||||
market.requested.add request
|
||||
market.state[request.id] = RequestState.New
|
||||
market.fillSlot(request.id, !agent.slotIndex, proof, Address.example)
|
||||
market.fillSlot(request.id, agent.slotIndex, proof, Address.example)
|
||||
await agent.switchAsync(SaleFilling())
|
||||
await sleepAsync chronos.seconds(2)
|
||||
|
||||
|
@ -519,7 +519,7 @@ suite "Sales state machine":
|
|||
await agent.start(request.ask.slots)
|
||||
market.requested.add request
|
||||
market.state[request.id] = RequestState.New
|
||||
await fillSlot(!agent.slotIndex)
|
||||
await fillSlot(agent.slotIndex)
|
||||
await agent.switchAsync(SaleDownloading())
|
||||
market.emitRequestFulfilled(request.id)
|
||||
await sleepAsync chronos.seconds(2)
|
||||
|
|
Loading…
Reference in New Issue