From 8086dda3f27a9dad815ac0b8483022c1f7d4188f Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Wed, 18 May 2022 13:27:01 +0200 Subject: [PATCH] [purchasing] set selected offer on purchase --- dagger/purchasing.nim | 1 + tests/dagger/testpurchasing.nim | 1 + 2 files changed, 2 insertions(+) diff --git a/dagger/purchasing.nim b/dagger/purchasing.nim index bc0f2cb05..1479e937d 100644 --- a/dagger/purchasing.nim +++ b/dagger/purchasing.nim @@ -81,6 +81,7 @@ proc selectOffer(purchase: Purchase) {.async.} = cheapest = some offer if cheapest =? cheapest: await purchase.market.selectOffer(cheapest.id) + purchase.selected = some cheapest proc run(purchase: Purchase) {.async.} = proc onOffer(offer: StorageOffer) = diff --git a/tests/dagger/testpurchasing.nim b/tests/dagger/testpurchasing.nim index dcec41af4..4b260ec50 100644 --- a/tests/dagger/testpurchasing.nim +++ b/tests/dagger/testpurchasing.nim @@ -92,6 +92,7 @@ suite "Purchasing": discard await market.offerStorage(offer2) clock.set(request.expiry.truncate(int64)) await purchase.wait() + check purchase.selected == some offer2 check market.selected[0] == offer2.id test "ignores offers that expired":