[purchasing] Remove fulfillRequest() from test
This commit is contained in:
parent
dc95c863d2
commit
ac6d17e895
|
@ -89,6 +89,21 @@ method getHost(market: MockMarket,
|
||||||
return some slot.host
|
return some slot.host
|
||||||
return none Address
|
return none Address
|
||||||
|
|
||||||
|
proc emitSlotFilled*(market: MockMarket,
|
||||||
|
requestId: array[32, byte],
|
||||||
|
slotIndex: UInt256) =
|
||||||
|
var subscriptions = market.subscriptions.onSlotFilled
|
||||||
|
for subscription in subscriptions:
|
||||||
|
if subscription.requestId == requestId and
|
||||||
|
subscription.slotIndex == slotIndex:
|
||||||
|
subscription.callback(requestId, slotIndex)
|
||||||
|
|
||||||
|
proc emitRequestFulfilled*(market: MockMarket, requestId: array[32, byte]) =
|
||||||
|
var subscriptions = market.subscriptions.onFulfillment
|
||||||
|
for subscription in subscriptions:
|
||||||
|
if subscription.requestId == requestId:
|
||||||
|
subscription.callback(requestId)
|
||||||
|
|
||||||
proc fillSlot*(market: MockMarket,
|
proc fillSlot*(market: MockMarket,
|
||||||
requestId: array[32, byte],
|
requestId: array[32, byte],
|
||||||
slotIndex: UInt256,
|
slotIndex: UInt256,
|
||||||
|
@ -101,11 +116,7 @@ proc fillSlot*(market: MockMarket,
|
||||||
host: host
|
host: host
|
||||||
)
|
)
|
||||||
market.filled.add(slot)
|
market.filled.add(slot)
|
||||||
var subscriptions = market.subscriptions.onSlotFilled
|
market.emitSlotFilled(requestId, slotIndex)
|
||||||
for subscription in subscriptions:
|
|
||||||
if subscription.requestId == requestId and
|
|
||||||
subscription.slotIndex == slotIndex:
|
|
||||||
subscription.callback(requestId, slotIndex)
|
|
||||||
|
|
||||||
method fillSlot*(market: MockMarket,
|
method fillSlot*(market: MockMarket,
|
||||||
requestId: array[32, byte],
|
requestId: array[32, byte],
|
||||||
|
|
|
@ -74,8 +74,7 @@ suite "Purchasing":
|
||||||
test "succeeds when request is fulfilled":
|
test "succeeds when request is fulfilled":
|
||||||
let purchase = purchasing.purchase(request)
|
let purchase = purchasing.purchase(request)
|
||||||
let request = market.requested[0]
|
let request = market.requested[0]
|
||||||
let proof = seq[byte].example
|
market.emitRequestFulfilled(request.id)
|
||||||
await market.fulfillRequest(request.id, proof)
|
|
||||||
await purchase.wait()
|
await purchase.wait()
|
||||||
check purchase.error.isNone
|
check purchase.error.isNone
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue