mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-05 15:03:07 +00:00
Add a template to stop the test when a storage request fails
This commit is contained in:
parent
f3311cca30
commit
69b0bf3b8a
@ -447,23 +447,24 @@ marketplacesuite(name = "Marketplace payouts"):
|
||||
|
||||
discard await waitForRequestToStart()
|
||||
|
||||
# Here we will check that for each provider, the total remaining collateral
|
||||
# will match the available slots.
|
||||
# So if a SP hosts 1 slot, it should have enough total remaining collateral
|
||||
# to host 2 more slots.
|
||||
for provider in providers():
|
||||
let client = provider.client
|
||||
check eventually(
|
||||
block:
|
||||
try:
|
||||
let availabilities = (await client.getAvailabilities()).get
|
||||
let availability = availabilities[0]
|
||||
let slots = (await client.getSlots()).get
|
||||
let availableSlots = (3 - slots.len).u256
|
||||
stopOnRequestFailed:
|
||||
# Here we will check that for each provider, the total remaining collateral
|
||||
# will match the available slots.
|
||||
# So if a SP hosts 1 slot, it should have enough total remaining collateral
|
||||
# to host 2 more slots.
|
||||
for provider in providers():
|
||||
let client = provider.client
|
||||
check eventually(
|
||||
block:
|
||||
try:
|
||||
let availabilities = (await client.getAvailabilities()).get
|
||||
let availability = availabilities[0]
|
||||
let slots = (await client.getSlots()).get
|
||||
let availableSlots = (3 - slots.len).u256
|
||||
|
||||
availability.totalRemainingCollateral ==
|
||||
availableSlots * slotSize * minPricePerBytePerSecond
|
||||
except HttpConnectionError:
|
||||
return false,
|
||||
timeout = 30 * 1000,
|
||||
)
|
||||
availability.totalRemainingCollateral ==
|
||||
availableSlots * slotSize * minPricePerBytePerSecond
|
||||
except HttpConnectionError:
|
||||
return false,
|
||||
timeout = 30 * 1000,
|
||||
)
|
||||
|
||||
@ -34,6 +34,36 @@ template marketplacesuite*(name: string, body: untyped) =
|
||||
if not cond:
|
||||
fail(reason)
|
||||
|
||||
template stopOnRequestFailed(tbody: untyped) =
|
||||
let completed = newAsyncEvent()
|
||||
|
||||
let mainFut = (
|
||||
proc(): Future[void] {.async.} =
|
||||
tbody
|
||||
completed.fire()
|
||||
)()
|
||||
|
||||
let fastFailFut = (
|
||||
proc(): Future[void] {.async.} =
|
||||
try:
|
||||
await requestFailedEvent.wait().wait(timeout = chronos.seconds(60))
|
||||
completed.fire()
|
||||
raise newException(TestFailedError, "storage request has failed")
|
||||
except AsyncTimeoutError:
|
||||
discard
|
||||
)()
|
||||
|
||||
await completed.wait().wait(timeout = chronos.seconds(60 * 30))
|
||||
|
||||
if not fastFailFut.completed:
|
||||
await fastFailFut.cancelAndWait()
|
||||
|
||||
if mainFut.failed:
|
||||
raise mainFut.error
|
||||
|
||||
if fastFailFut.failed:
|
||||
raise fastFailFut.error
|
||||
|
||||
proc onRequestStarted(eventResult: ?!RequestFulfilled) {.raises: [].} =
|
||||
requestStartedEvent.fire()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user