[WIP sales] fulfill request
This commit is contained in:
parent
5abd5dd674
commit
a2570f9380
|
@ -147,6 +147,7 @@ proc start(negotiation: Negotiation) {.async.} =
|
||||||
|
|
||||||
await retrieve(request.content.cid)
|
await retrieve(request.content.cid)
|
||||||
let proof = await prove(request.content.cid)
|
let proof = await prove(request.content.cid)
|
||||||
|
await market.fulfillRequest(request.id, proof)
|
||||||
|
|
||||||
await negotiation.sendOffer()
|
await negotiation.sendOffer()
|
||||||
await negotiation.subscribeSelect()
|
await negotiation.subscribeSelect()
|
||||||
|
|
|
@ -10,9 +10,9 @@ type
|
||||||
signer: Address
|
signer: Address
|
||||||
subscriptions: Subscriptions
|
subscriptions: Subscriptions
|
||||||
Fulfillment* = object
|
Fulfillment* = object
|
||||||
requestId: array[32, byte]
|
requestId*: array[32, byte]
|
||||||
proof: seq[byte]
|
proof*: seq[byte]
|
||||||
host: Address
|
host*: Address
|
||||||
Subscriptions = object
|
Subscriptions = object
|
||||||
onRequest: seq[RequestSubscription]
|
onRequest: seq[RequestSubscription]
|
||||||
onFulfillment: seq[FulfillmentSubscription]
|
onFulfillment: seq[FulfillmentSubscription]
|
||||||
|
|
|
@ -23,6 +23,7 @@ suite "Sales":
|
||||||
cid: "some cid"
|
cid: "some cid"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
let proof = seq[byte].example
|
||||||
|
|
||||||
var sales: Sales
|
var sales: Sales
|
||||||
var market: MockMarket
|
var market: MockMarket
|
||||||
|
@ -33,7 +34,7 @@ suite "Sales":
|
||||||
clock = MockClock.new()
|
clock = MockClock.new()
|
||||||
sales = Sales.new(market, clock)
|
sales = Sales.new(market, clock)
|
||||||
sales.retrieve = proc(_: string) {.async.} = discard
|
sales.retrieve = proc(_: string) {.async.} = discard
|
||||||
sales.prove = proc(_: string): Future[seq[byte]] {.async.} = discard
|
sales.prove = proc(_: string): Future[seq[byte]] {.async.} = return proof
|
||||||
await sales.start()
|
await sales.start()
|
||||||
|
|
||||||
teardown:
|
teardown:
|
||||||
|
@ -94,6 +95,14 @@ suite "Sales":
|
||||||
discard await market.requestStorage(request)
|
discard await market.requestStorage(request)
|
||||||
check provingCid == request.content.cid
|
check provingCid == request.content.cid
|
||||||
|
|
||||||
|
test "fulfills request":
|
||||||
|
sales.add(availability)
|
||||||
|
discard await market.requestStorage(request)
|
||||||
|
check market.fulfilled.len == 1
|
||||||
|
check market.fulfilled[0].requestId == request.id
|
||||||
|
check market.fulfilled[0].proof == proof
|
||||||
|
check market.fulfilled[0].host == await market.getSigner()
|
||||||
|
|
||||||
# test "calls onSale when offer is selected":
|
# test "calls onSale when offer is selected":
|
||||||
# var sold: StorageOffer
|
# var sold: StorageOffer
|
||||||
# sales.onSale = proc(offer: StorageOffer) =
|
# sales.onSale = proc(offer: StorageOffer) =
|
||||||
|
|
Loading…
Reference in New Issue