diff --git a/tests/codex/helpers/mockmarket.nim b/tests/codex/helpers/mockmarket.nim index 3fe55173..0ffce3ce 100644 --- a/tests/codex/helpers/mockmarket.nim +++ b/tests/codex/helpers/mockmarket.nim @@ -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], diff --git a/tests/codex/testpurchasing.nim b/tests/codex/testpurchasing.nim index 0e7447ab..d54dc61a 100644 --- a/tests/codex/testpurchasing.nim +++ b/tests/codex/testpurchasing.nim @@ -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