test: make `proc finish` async in "nodes negotiate ..." integration test
`waitFor` has been moved into the main body of integration test `nodes negotiate ...` to reduce blockage on the main thread. That change, along with widening the expiry in `when defined(windows)` (and bumping up `timeout-minutes` in our CI workflow) allows Windows CI builds to succeed more consistently, i.e. without timing out.
This commit is contained in:
parent
19407622e7
commit
8f0bc54fba
|
@ -77,7 +77,6 @@ ethersuite "Integration tests":
|
|||
check json["request"]["ask"]["maxPrice"].getStr == "0x2"
|
||||
|
||||
test "nodes negotiate contracts on the marketplace":
|
||||
|
||||
proc sell =
|
||||
let json = %*{"size": "0x1F00", "duration": "0x200", "minPrice": "0x300"}
|
||||
discard client.post(baseurl2 & "/sales/availability", $json)
|
||||
|
@ -89,20 +88,23 @@ ethersuite "Integration tests":
|
|||
client.post(baseurl1 & "/upload", "some file contents").body
|
||||
|
||||
proc buy(cid: string): string =
|
||||
let expiry = ((waitFor provider.currentTime()) + 10).toHex
|
||||
when defined(windows):
|
||||
# Windows builds in GitHub Actions need a longer expiry
|
||||
let expiry = ((waitFor provider.currentTime()) + 30).toHex
|
||||
else:
|
||||
let expiry = ((waitFor provider.currentTime()) + 10).toHex
|
||||
let json = %*{"duration": "0x100", "maxPrice": "0x400", "expiry": expiry}
|
||||
client.post(baseurl1 & "/storage/request/" & cid, $json).body
|
||||
|
||||
proc finish(purchase: string): JsonNode =
|
||||
proc finish(purchase: string): Future[JsonNode] {.async.} =
|
||||
while true:
|
||||
let response = client.get(baseurl1 & "/storage/purchases/" & purchase)
|
||||
result = parseJson(response.body)
|
||||
if result["finished"].getBool:
|
||||
break
|
||||
waitFor sleepAsync(1.seconds)
|
||||
let json = parseJson(response.body)
|
||||
if json["finished"].getBool: return json
|
||||
await sleepAsync(1.seconds)
|
||||
|
||||
sell()
|
||||
let purchase = upload().buy().finish()
|
||||
let purchase = waitFor upload().buy().finish()
|
||||
|
||||
check purchase["error"].getStr == ""
|
||||
check purchase["selected"].len > 0
|
||||
|
|
Loading…
Reference in New Issue