From 8f0bc54fba67bca191c8b7694488290f4aa21104 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Sun, 3 Jul 2022 21:33:55 -0500 Subject: [PATCH] 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. --- tests/testIntegration.nim | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/testIntegration.nim b/tests/testIntegration.nim index 7796f80d..4f4d3dd9 100644 --- a/tests/testIntegration.nim +++ b/tests/testIntegration.nim @@ -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