From 34182ee92f4baa65d49b521155e7f2ddc3ed4160 Mon Sep 17 00:00:00 2001 From: Marcin Czenko Date: Wed, 16 Oct 2024 04:13:58 +0200 Subject: [PATCH] uses http as default RPC provider for nodes running in integration tests as a workaround for dropped subscriptions --- tests/integration/multinodes.nim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/integration/multinodes.nim b/tests/integration/multinodes.nim index 983466ae..ddb875df 100644 --- a/tests/integration/multinodes.nim +++ b/tests/integration/multinodes.nim @@ -67,6 +67,10 @@ template multinodesuite*(name: string, body: untyped) = let starttime = now().format("yyyy-MM-dd'_'HH:mm:ss") var currentTestName = "" var nodeConfigs: NodeConfigs + # Workaround for https://github.com/NomicFoundation/hardhat/issues/2053 + # Do not use websockets, but use http and polling to stop subscriptions + # from being removed after 5 minutes + let defaultProviderUrl = "http://127.0.0.1:8545" var ethProvider {.inject, used.}: JsonRpcProvider var accounts {.inject, used.}: seq[Address] var snapshot: JsonNode @@ -196,7 +200,7 @@ template multinodesuite*(name: string, body: untyped) = proc startClientNode(conf: CodexConfig): Future[NodeProcess] {.async.} = let clientIdx = clients().len var config = conf - config.addCliOption(StartUpCmd.persistence, "--eth-provider", "http://127.0.0.1:8545") + config.addCliOption(StartUpCmd.persistence, "--eth-provider", defaultProviderUrl) config.addCliOption(StartUpCmd.persistence, "--eth-account", $accounts[running.len]) return await newCodexProcess(clientIdx, config, Role.Client) @@ -204,7 +208,7 @@ template multinodesuite*(name: string, body: untyped) = let providerIdx = providers().len var config = conf config.addCliOption("--bootstrap-node", bootstrap) - config.addCliOption(StartUpCmd.persistence, "--eth-provider", "http://127.0.0.1:8545") + config.addCliOption(StartUpCmd.persistence, "--eth-provider", defaultProviderUrl) config.addCliOption(StartUpCmd.persistence, "--eth-account", $accounts[running.len]) config.addCliOption(PersistenceCmd.prover, "--circom-r1cs", "vendor/codex-contracts-eth/verifier/networks/hardhat/proof_main.r1cs") @@ -219,7 +223,7 @@ template multinodesuite*(name: string, body: untyped) = let validatorIdx = validators().len var config = conf config.addCliOption("--bootstrap-node", bootstrap) - config.addCliOption(StartUpCmd.persistence, "--eth-provider", "http://127.0.0.1:8545") + config.addCliOption(StartUpCmd.persistence, "--eth-provider", defaultProviderUrl) config.addCliOption(StartUpCmd.persistence, "--eth-account", $accounts[running.len]) config.addCliOption(StartUpCmd.persistence, "--validator") @@ -268,7 +272,7 @@ template multinodesuite*(name: string, body: untyped) = # Do not use websockets, but use http and polling to stop subscriptions # from being removed after 5 minutes ethProvider = JsonRpcProvider.new( - "http://127.0.0.1:8545", + defaultProviderUrl, pollingInterval = chronos.milliseconds(100) ) # if hardhat was NOT started by the test, take a snapshot so it can be