diff --git a/codex/sales.nim b/codex/sales.nim index dc1ecb55..f62253af 100644 --- a/codex/sales.nim +++ b/codex/sales.nim @@ -153,6 +153,7 @@ proc start(negotiation: Negotiation) {.async.} = negotiation.waiting = some negotiation.waitForExpiry() except CatchableError as e: error "Negotiation failed", msg = e.msg + negotiation.finish(success = false) proc handleRequest(sales: Sales, requestId: array[32, byte], ask: StorageAsk) = without availability =? sales.findAvailability(ask): diff --git a/tests/codex/testsales.nim b/tests/codex/testsales.nim index 191f16bb..280a383f 100644 --- a/tests/codex/testsales.nim +++ b/tests/codex/testsales.nim @@ -80,6 +80,13 @@ suite "Sales": discard await market.requestStorage(request) check retrievingCid == request.content.cid + test "makes storage available again when data retrieval fails": + let error = newException(IOError, "data retrieval failed") + sales.retrieve = proc(cid: string) {.async.} = raise error + sales.add(availability) + discard await market.requestStorage(request) + check sales.available == @[availability] + test "generates proof of storage": var provingCid: string sales.prove = proc(cid: string): Future[seq[byte]] {.async.} = provingCid = cid