[purchasing] Remove fulfillRequest() from test

This commit is contained in:
Mark Spanbroek 2022-07-21 14:48:35 +02:00 committed by markspanbroek
parent dc95c863d2
commit ac6d17e895
2 changed files with 17 additions and 7 deletions

View File

@ -89,6 +89,21 @@ method getHost(market: MockMarket,
return some slot.host
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,
requestId: array[32, byte],
slotIndex: UInt256,
@ -101,11 +116,7 @@ proc fillSlot*(market: MockMarket,
host: host
)
market.filled.add(slot)
var subscriptions = market.subscriptions.onSlotFilled
for subscription in subscriptions:
if subscription.requestId == requestId and
subscription.slotIndex == slotIndex:
subscription.callback(requestId, slotIndex)
market.emitSlotFilled(requestId, slotIndex)
method fillSlot*(market: MockMarket,
requestId: array[32, byte],

View File

@ -74,8 +74,7 @@ suite "Purchasing":
test "succeeds when request is fulfilled":
let purchase = purchasing.purchase(request)
let request = market.requested[0]
let proof = seq[byte].example
await market.fulfillRequest(request.id, proof)
market.emitRequestFulfilled(request.id)
await purchase.wait()
check purchase.error.isNone