Skip to content

Commit

Permalink
[purchasing] set selected offer on purchase
Browse files Browse the repository at this point in the history
  • Loading branch information
markspanbroek committed May 19, 2022
1 parent d8ef633 commit 8086dda
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions dagger/purchasing.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down
1 change: 1 addition & 0 deletions tests/dagger/testpurchasing.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down

0 comments on commit 8086dda

Please sign in to comment.