diff --git a/tests/integration/codexclient.nim b/tests/integration/codexclient.nim index e3409b82..e693594a 100644 --- a/tests/integration/codexclient.nim +++ b/tests/integration/codexclient.nim @@ -24,6 +24,15 @@ proc info*(client: CodexClient): JsonNode = let url = client.baseurl & "/debug/info" client.http.getContent(url).parseJson() +proc isAvailable*(client: CodexClient): bool = + try: + discard client.info + return true + except OSError as e: + if e.msg == "Connection refused": + return false + raise e + proc setLogLevel*(client: CodexClient, level: string) = let url = client.baseurl & "/debug/chronicles/loglevel?level=" & level let headers = newHttpHeaders({"Content-Type": "text/plain"}) diff --git a/tests/integration/marketplacesuite.nim b/tests/integration/marketplacesuite.nim index a2454c9b..f5afa415 100644 --- a/tests/integration/marketplacesuite.nim +++ b/tests/integration/marketplacesuite.nim @@ -90,30 +90,16 @@ template marketplacesuite*(name: string, body: untyped) = discard setup: - echo ">>> [marketplacesuite.setup] setup start" marketplace = Marketplace.new(Marketplace.address, ethProvider.getSigner()) - echo ">>> [marketplacesuite.setup] setup 1" let tokenAddress = await marketplace.token() - echo ">>> [marketplacesuite.setup] setup 2" token = Erc20Token.new(tokenAddress, ethProvider.getSigner()) - echo ">>> [marketplacesuite.setup] setup 3" let config = await mp.config(marketplace) - echo ">>> [marketplacesuite.setup] setup 4" period = config.proofs.period.truncate(uint64) - echo ">>> [marketplacesuite.setup] setup 5" periodicity = Periodicity(seconds: period.u256) - echo ">>> [marketplacesuite.setup] setup 6" - when defined(windows): - let millis = chronos.millis(500) - else: - let millis = chronos.millis(1000) - continuousMineFut = continuouslyAdvanceEvery(millis) - echo ">>> [marketplacesuite.setup] setup 7" + continuousMineFut = continuouslyAdvanceEvery(chronos.millis(500)) teardown: - echo ">>> [marketplacesuite.teardown] teardown start" await continuousMineFut.cancelAndWait() - echo ">>> [marketplacesuite.teardown] teardown end" body diff --git a/tests/integration/nodes.nim b/tests/integration/nodes.nim index 0f796a44..8c7787d7 100644 --- a/tests/integration/nodes.nim +++ b/tests/integration/nodes.nim @@ -40,7 +40,8 @@ proc start(node: NodeProcess) = node.process = osproc.startProcess( executable, workingDir, - node.arguments + node.arguments, + options={poStdErrToStdOut, poInteractive} ) proc waitUntilOutput*(node: NodeProcess, output: string) = @@ -52,12 +53,6 @@ proc waitUntilOutput*(node: NodeProcess, output: string) = return raiseAssert "node did not output '" & output & "'" -proc waitUntilStarted*(node: NodeProcess) = - if node.debug or defined(windows): - sleep(5_000) - else: - node.waitUntilOutput("Started codex node") - proc startNode*(args: openArray[string], debug: string | bool = false): NodeProcess = ## Starts a Codex Node with the specified arguments. ## Set debug to 'true' to see output of the node. @@ -84,6 +79,12 @@ proc client*(node: NodeProcess): CodexClient = node.client = some client client +proc waitUntilStarted*(node: NodeProcess) = + while true: + if client(node).isAvailable: + break + sleep(1) + method stop*(node: NodeProcess) {.base.} = if node.process != nil: node.process.terminate() diff --git a/tests/integration/testproofs.nim b/tests/integration/testproofs.nim index 0d0c4ce2..6c2896e0 100644 --- a/tests/integration/testproofs.nim +++ b/tests/integration/testproofs.nim @@ -22,14 +22,14 @@ marketplacesuite "Hosts submit regular proofs": clients: NodeConfig() .nodes(1) - .debug() # uncomment to enable console log output + # .debug() # uncomment to enable console log output .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log .withLogTopics("node"), providers: NodeConfig() .nodes(1) - .debug() # uncomment to enable console log output + # .debug() # uncomment to enable console log output .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log .withLogTopics("marketplace", "sales", "reservations", "node"), ): @@ -71,7 +71,7 @@ marketplacesuite "Simulate invalid proofs": clients: NodeConfig() .nodes(1) - .debug() # uncomment to enable console log output + # .debug() # uncomment to enable console log output .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log .withLogTopics("node"), @@ -79,7 +79,7 @@ marketplacesuite "Simulate invalid proofs": NodeConfig() .nodes(1) .simulateProofFailuresFor(providerIdx=0, failEveryNProofs=1) - .debug() # uncomment to enable console log output + # .debug() # uncomment to enable console log output .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log .withLogTopics("marketplace", "sales", "reservations", "node"), @@ -87,7 +87,7 @@ marketplacesuite "Simulate invalid proofs": NodeConfig() .nodes(1) .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log - .debug() # uncomment to enable console log output + # .debug() # uncomment to enable console log output .withLogTopics("validator", "onchain", "ethers") ): let client0 = clients()[0].node.client @@ -123,7 +123,7 @@ marketplacesuite "Simulate invalid proofs": clients: NodeConfig() .nodes(1) - .debug() # uncomment to enable console log output + # .debug() # uncomment to enable console log output .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log .withLogTopics("node"), @@ -131,14 +131,14 @@ marketplacesuite "Simulate invalid proofs": NodeConfig() .nodes(1) .simulateProofFailuresFor(providerIdx=0, failEveryNProofs=3) - .debug() # uncomment to enable console log output + # .debug() # uncomment to enable console log output .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log .withLogTopics("marketplace", "sales", "reservations", "node"), validators: NodeConfig() .nodes(1) - .debug() + # .debug() .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log .withLogTopics("validator", "onchain", "ethers") ): @@ -176,7 +176,7 @@ marketplacesuite "Simulate invalid proofs": clients: NodeConfig() .nodes(1) - .debug() # uncomment to enable console log output.debug() + # .debug() # uncomment to enable console log output.debug() .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log .withLogTopics("node", "erasure", "clock", "purchases"), @@ -184,14 +184,14 @@ marketplacesuite "Simulate invalid proofs": NodeConfig() .nodes(2) .simulateProofFailuresFor(providerIdx=0, failEveryNProofs=2) - .debug() # uncomment to enable console log output + # .debug() # uncomment to enable console log output .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log .withLogTopics("marketplace", "sales", "reservations", "node"), validators: NodeConfig() .nodes(1) - .debug() + # .debug() .withLogFile() # uncomment to output log file to tests/integration/logs/ //_.log .withLogTopics("validator") ):