diff --git a/codex/sales.nim b/codex/sales.nim index 91dcbd06..5cecf9bc 100644 --- a/codex/sales.nim +++ b/codex/sales.nim @@ -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) diff --git a/codex/sales/salesagent.nim b/codex/sales/salesagent.nim index 99f5c72c..bfeb8530 100644 --- a/codex/sales/salesagent.nim +++ b/codex/sales/salesagent.nim @@ -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, diff --git a/codex/sales/statemachine.nim b/codex/sales/statemachine.nim index 568e00ba..2c0af540 100644 --- a/codex/sales/statemachine.nim +++ b/codex/sales/statemachine.nim @@ -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 diff --git a/tests/codex/testsales.nim b/tests/codex/testsales.nim index bebe7712..dba08957 100644 --- a/tests/codex/testsales.nim +++ b/tests/codex/testsales.nim @@ -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)