Feat/bump questionable (#627)
* Bumps questionable version to 0.10.12 * removes unnecessary questionnable bindings. * Fixes tests * unnecessary whitespaces
This commit is contained in:
parent
40d7714a67
commit
bece1b88a1
|
@ -20,7 +20,7 @@ requires "nimcrypto >= 0.4.1"
|
|||
requires "nitro >= 0.5.1 & < 0.6.0"
|
||||
requires "presto"
|
||||
requires "protobuf_serialization >= 0.2.0 & < 0.3.0"
|
||||
requires "questionable >= 0.10.6 & < 0.11.0"
|
||||
requires "questionable >= 0.10.12 & < 0.11.0"
|
||||
requires "secp256k1"
|
||||
requires "stew"
|
||||
requires "upraises >= 0.1.0 & < 0.2.0"
|
||||
|
|
|
@ -181,7 +181,7 @@ proc getImpl(
|
|||
self: Reservations,
|
||||
key: Key): Future[?!seq[byte]] {.async.} =
|
||||
|
||||
if exists =? (await self.exists(key)) and not exists:
|
||||
if not await self.exists(key):
|
||||
let err = newException(NotExistsError, "object with key " & $key & " does not exist")
|
||||
return failure(err)
|
||||
|
||||
|
@ -226,7 +226,7 @@ proc delete(
|
|||
|
||||
trace "deleting object", key
|
||||
|
||||
if exists =? (await self.exists(key)) and not exists:
|
||||
if not await self.exists(key):
|
||||
return success()
|
||||
|
||||
if err =? (await self.repo.metaDs.delete(key)).errorOption:
|
||||
|
|
|
@ -20,19 +20,15 @@ method run*(state: SaleCancelled, machine: Machine): Future[?State] {.async.} =
|
|||
without request =? data.request:
|
||||
raiseAssert "no sale request"
|
||||
|
||||
without slotIndex =? data.slotIndex:
|
||||
raiseAssert("no slot index assigned")
|
||||
|
||||
let slot = Slot(request: request, slotIndex: slotIndex)
|
||||
debug "Collecting collateral and partial payout", requestId = $data.requestId, slotIndex
|
||||
let slot = Slot(request: request, slotIndex: data.slotIndex)
|
||||
debug "Collecting collateral and partial payout", requestId = $data.requestId, slotIndex = $data.slotIndex
|
||||
await market.freeSlot(slot.id)
|
||||
|
||||
if onClear =? agent.context.onClear and
|
||||
request =? data.request and
|
||||
slotIndex =? data.slotIndex:
|
||||
onClear(request, slotIndex)
|
||||
request =? data.request:
|
||||
onClear(request, data.slotIndex)
|
||||
|
||||
if onCleanUp =? agent.onCleanUp:
|
||||
await onCleanUp()
|
||||
|
||||
warn "Sale cancelled due to timeout", requestId = $data.requestId, slotIndex
|
||||
warn "Sale cancelled due to timeout", requestId = $data.requestId, slotIndex = $data.slotIndex
|
||||
|
|
|
@ -42,15 +42,12 @@ method run*(state: SaleDownloading, machine: Machine): Future[?State] {.async.}
|
|||
without request =? data.request:
|
||||
raiseAssert "no sale request"
|
||||
|
||||
without slotIndex =? data.slotIndex:
|
||||
raiseAssert("no slot index assigned")
|
||||
|
||||
without reservation =? data.reservation:
|
||||
raiseAssert("no reservation")
|
||||
|
||||
logScope:
|
||||
requestId = request.id
|
||||
slotIndex
|
||||
slotIndex = data.slotIndex
|
||||
reservationId = reservation.id
|
||||
availabilityId = reservation.availabilityId
|
||||
|
||||
|
@ -72,7 +69,7 @@ method run*(state: SaleDownloading, machine: Machine): Future[?State] {.async.}
|
|||
|
||||
trace "Starting download"
|
||||
if err =? (await onStore(request,
|
||||
slotIndex,
|
||||
data.slotIndex,
|
||||
onBatch)).errorOption:
|
||||
return some State(SaleErrored(error: err))
|
||||
|
||||
|
|
|
@ -25,9 +25,8 @@ method run*(state: SaleErrored, machine: Machine): Future[?State] {.async.} =
|
|||
error "Sale error", error=state.error.msgDetail, requestId = data.requestId, slotIndex = data.slotIndex
|
||||
|
||||
if onClear =? context.onClear and
|
||||
request =? data.request and
|
||||
slotIndex =? data.slotIndex:
|
||||
onClear(request, slotIndex)
|
||||
request =? data.request:
|
||||
onClear(request, data.slotIndex)
|
||||
|
||||
if onCleanUp =? agent.onCleanUp:
|
||||
await onCleanUp()
|
||||
|
|
|
@ -20,11 +20,8 @@ method run*(state: SaleFailed, machine: Machine): Future[?State] {.async.} =
|
|||
without request =? data.request:
|
||||
raiseAssert "no sale request"
|
||||
|
||||
without slotIndex =? data.slotIndex:
|
||||
raiseAssert("no slot index assigned")
|
||||
|
||||
let slot = Slot(request: request, slotIndex: slotIndex)
|
||||
debug "Removing slot from mySlots", requestId = $data.requestId, slotIndex
|
||||
let slot = Slot(request: request, slotIndex: data.slotIndex)
|
||||
debug "Removing slot from mySlots", requestId = $data.requestId, slotIndex = $data.slotIndex
|
||||
await market.freeSlot(slot.id)
|
||||
|
||||
let error = newException(SaleFailedError, "Sale failed")
|
||||
|
|
|
@ -29,19 +29,17 @@ method run*(state: SaleFilled, machine: Machine): Future[?State] {.async.} =
|
|||
let agent = SalesAgent(machine)
|
||||
let data = agent.data
|
||||
let context = agent.context
|
||||
|
||||
let market = context.market
|
||||
|
||||
without slotIndex =? data.slotIndex:
|
||||
raiseAssert("no slot index assigned")
|
||||
|
||||
let host = await market.getHost(data.requestId, slotIndex)
|
||||
let host = await market.getHost(data.requestId, data.slotIndex)
|
||||
let me = await market.getSigner()
|
||||
if host == me.some:
|
||||
info "Slot succesfully filled", requestId = $data.requestId, slotIndex
|
||||
|
||||
if request =? data.request and slotIndex =? data.slotIndex:
|
||||
if host == me.some:
|
||||
info "Slot succesfully filled", requestId = $data.requestId, slotIndex = $data.slotIndex
|
||||
|
||||
if request =? data.request:
|
||||
if onFilled =? agent.onFilled:
|
||||
onFilled(request, slotIndex)
|
||||
onFilled(request, data.slotIndex)
|
||||
|
||||
when codex_enable_proof_failures:
|
||||
if context.simulateProofFailures > 0:
|
||||
|
|
|
@ -32,8 +32,5 @@ method run(state: SaleFilling, machine: Machine): Future[?State] {.async.} =
|
|||
without (collateral =? data.request.?ask.?collateral):
|
||||
raiseAssert "Request not set"
|
||||
|
||||
without slotIndex =? data.slotIndex:
|
||||
raiseAssert("no slot index assigned")
|
||||
|
||||
debug "Filling slot", requestId = $data.requestId, slotIndex
|
||||
await market.fillSlot(data.requestId, slotIndex, state.proof, collateral)
|
||||
debug "Filling slot", requestId = $data.requestId, slotIndex = $data.slotIndex
|
||||
await market.fillSlot(data.requestId, data.slotIndex, state.proof, collateral)
|
||||
|
|
|
@ -27,10 +27,7 @@ method run*(state: SaleFinished, machine: Machine): Future[?State] {.async.} =
|
|||
without request =? data.request:
|
||||
raiseAssert "no sale request"
|
||||
|
||||
without slotIndex =? data.slotIndex:
|
||||
raiseAssert("no slot index assigned")
|
||||
|
||||
info "Slot finished and paid out", requestId = $data.requestId, slotIndex
|
||||
info "Slot finished and paid out", requestId = $data.requestId, slotIndex = $data.slotIndex
|
||||
|
||||
if onCleanUp =? agent.onCleanUp:
|
||||
await onCleanUp()
|
||||
|
|
|
@ -30,11 +30,8 @@ method run*(state: SaleInitialProving, machine: Machine): Future[?State] {.async
|
|||
without onProve =? context.onProve:
|
||||
raiseAssert "onProve callback not set"
|
||||
|
||||
without slotIndex =? data.slotIndex:
|
||||
raiseAssert("no slot index assigned")
|
||||
|
||||
debug "Generating initial proof", requestId = $data.requestId
|
||||
let proof = await onProve(Slot(request: request, slotIndex: slotIndex))
|
||||
let proof = await onProve(Slot(request: request, slotIndex: data.slotIndex))
|
||||
debug "Finished proof calculation", requestId = $data.requestId
|
||||
|
||||
return some State(SaleFilling(proof: proof))
|
||||
|
|
|
@ -28,11 +28,8 @@ method run(state: SalePayout, machine: Machine): Future[?State] {.async.} =
|
|||
without request =? data.request:
|
||||
raiseAssert "no sale request"
|
||||
|
||||
without slotIndex =? data.slotIndex:
|
||||
raiseAssert("no slot index assigned")
|
||||
|
||||
let slot = Slot(request: request, slotIndex: slotIndex)
|
||||
debug "Collecting finished slot's reward", requestId = $data.requestId, slotIndex
|
||||
let slot = Slot(request: request, slotIndex: data.slotIndex)
|
||||
debug "Collecting finished slot's reward", requestId = $data.requestId, slotIndex = $data.slotIndex
|
||||
await market.freeSlot(slot.id)
|
||||
|
||||
return some State(SaleFinished())
|
||||
|
|
|
@ -112,18 +112,15 @@ method run*(state: SaleProving, machine: Machine): Future[?State] {.async.} =
|
|||
without onProve =? context.onProve:
|
||||
raiseAssert "onProve callback not set"
|
||||
|
||||
without slotIndex =? data.slotIndex:
|
||||
raiseAssert("no slot index assigned")
|
||||
|
||||
without market =? context.market:
|
||||
raiseAssert("market not set")
|
||||
|
||||
without clock =? context.clock:
|
||||
raiseAssert("clock not set")
|
||||
|
||||
debug "Start proving", requestId = $data.requestId, slotIndex
|
||||
debug "Start proving", requestId = $data.requestId, slotIndex = $data.slotIndex
|
||||
try:
|
||||
let loop = state.proveLoop(market, clock, request, slotIndex, onProve)
|
||||
let loop = state.proveLoop(market, clock, request, data.slotIndex, onProve)
|
||||
state.loop = loop
|
||||
await loop
|
||||
except CancelledError:
|
||||
|
@ -133,7 +130,7 @@ method run*(state: SaleProving, machine: Machine): Future[?State] {.async.} =
|
|||
return some State(SaleErrored(error: e))
|
||||
finally:
|
||||
# Cleanup of the proving loop
|
||||
debug "Stopping proving.", requestId = $data.requestId, slotIndex
|
||||
debug "Stopping proving.", requestId = $data.requestId, slotIndex = $data.slotIndex
|
||||
|
||||
if not state.loop.isNil:
|
||||
if not state.loop.finished:
|
||||
|
|
|
@ -32,14 +32,8 @@ method run*(state: SaleUnknown, machine: Machine): Future[?State] {.async.} =
|
|||
await agent.retrieveRequest()
|
||||
await agent.subscribe()
|
||||
|
||||
without slotIndex =? data.slotIndex:
|
||||
raiseAssert("no slot index assigned")
|
||||
|
||||
let slotId = slotId(data.requestId, slotIndex)
|
||||
|
||||
without slotState =? await market.slotState(slotId):
|
||||
let error = newException(SaleUnknownError, "cannot retrieve slot state")
|
||||
return some State(SaleErrored(error: error))
|
||||
let slotId = slotId(data.requestId, data.slotIndex)
|
||||
let slotState = await market.slotState(slotId)
|
||||
|
||||
case slotState
|
||||
of SlotState.Free:
|
||||
|
|
|
@ -83,8 +83,7 @@ asyncchecksuite "Reservations module":
|
|||
test "reserved availability exists":
|
||||
let availability = createAvailability()
|
||||
|
||||
without exists =? await reservations.exists(availability.key.get):
|
||||
fail()
|
||||
let exists = await reservations.exists(availability.key.get)
|
||||
|
||||
check exists
|
||||
|
||||
|
|
|
@ -88,5 +88,4 @@ proc restart*(node: NodeProcess) =
|
|||
node.waitUntilStarted()
|
||||
|
||||
proc removeDataDir*(node: NodeProcess) =
|
||||
if dataDir =? node.dataDir:
|
||||
removeDir(dataDir)
|
||||
removeDir(node.dataDir)
|
||||
|
|
|
@ -22,7 +22,9 @@ import ./twonodes
|
|||
twonodessuite "Integration tests", debug1 = false, debug2 = false:
|
||||
|
||||
proc purchaseStateIs(client: CodexClient, id: PurchaseId, state: string): bool =
|
||||
client.getPurchase(id).option.?state == some state
|
||||
without purchase =? client.getPurchase(id):
|
||||
return false
|
||||
return purchase.state == state
|
||||
|
||||
setup:
|
||||
# Our Hardhat configuration does use automine, which means that time tracked by `provider.currentTime()` is not
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit e56cf86c4a089c78a1b7c3005f13343bfbbe3b48
|
||||
Subproject commit 2dd6b6b220f9f14a1231f6cafdf24f012bcc8414
|
Loading…
Reference in New Issue