From dfa845abf85e7fd8f947fce0539011d65412ab2c 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 14b48019..c309d45a 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://localhost:8545" var ethProvider {.inject, used.}: JsonRpcProvider var accounts {.inject, used.}: seq[Address] var snapshot: JsonNode @@ -196,6 +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", defaultProviderUrl) config.addCliOption(StartUpCmd.persistence, "--eth-account", $accounts[running.len]) return await newCodexProcess(clientIdx, config, Role.Client) @@ -203,6 +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", 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") @@ -217,6 +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", defaultProviderUrl) config.addCliOption(StartUpCmd.persistence, "--eth-account", $accounts[running.len]) config.addCliOption(StartUpCmd.persistence, "--validator") @@ -261,10 +268,7 @@ template multinodesuite*(name: string, body: untyped) = quit(1) try: - # 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 - ethProvider = JsonRpcProvider.new("http://localhost:8545") + ethProvider = JsonRpcProvider.new(defaultProviderUrl) # if hardhat was NOT started by the test, take a snapshot so it can be # reverted in the test teardown if nodeConfigs.hardhat.isNone: