From a7f3ead44e6f9fdedafb929f2c744767c4521d28 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 5 Jul 2022 10:29:02 +0200 Subject: [PATCH] [WIP sales] refactor tests --- tests/codex/testsales.nim | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/tests/codex/testsales.nim b/tests/codex/testsales.nim index d09743f7..191f16bb 100644 --- a/tests/codex/testsales.nim +++ b/tests/codex/testsales.nim @@ -61,27 +61,25 @@ suite "Sales": let availability2 = Availability.init(1.u256, 2.u256, 3.u256) check availability1.id != availability2.id - test "retrieves data when matching request comes in": + test "makes storage unavailable when matching request comes in": + sales.add(availability) + discard await market.requestStorage(request) + check sales.available.len == 0 + + test "ignores request when no matching storage is available": + sales.add(availability) + var tooBig = request + tooBig.ask.size = request.ask.size + 1 + discard await market.requestStorage(tooBig) + check sales.available == @[availability] + + test "retrieves data": var retrievingCid: string sales.retrieve = proc(cid: string) {.async.} = retrievingCid = cid sales.add(availability) discard await market.requestStorage(request) check retrievingCid == request.content.cid - test "ignores request when no matching storage is available": - var retrieveCalled = false - sales.retrieve = proc(cid: string) {.async.} = retrieveCalled = true - sales.add(availability) - var tooBig = request - tooBig.ask.size = request.ask.size + 1 - discard await market.requestStorage(tooBig) - check not retrieveCalled - - test "makes storage unavailable when offer is submitted": - sales.add(availability) - discard await market.requestStorage(request) - check sales.available.len == 0 - test "generates proof of storage": var provingCid: string sales.prove = proc(cid: string): Future[seq[byte]] {.async.} = provingCid = cid @@ -89,12 +87,6 @@ suite "Sales": discard await market.requestStorage(request) check provingCid == request.content.cid - # test "sets expiry time of offer": - # sales.add(availability) - # let now = clock.now().u256 - # discard await market.requestStorage(request) - # check market.offered[0].expiry == now + sales.offerExpiryInterval - # test "calls onSale when offer is selected": # var sold: StorageOffer # sales.onSale = proc(offer: StorageOffer) =