From 6ff4d30b43d5ea4cd3e367b7a690305eacdc535a Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:10:36 +0700 Subject: [PATCH] fix(tests/integration): fix bootstrap node spr (#1048) After a change in PR #1031, bootstrap node sprs may not work when Hardhat nodes are started with the tests. This fixes it by appending all started client's and provider's SPR to a sequence, and using that sequence of SPRs to start the next node. This means all subsequently started nodes will be connected to its previously started peers. This also fixes the case when bootstrap SPRs would not be present if no clients were started. --- tests/integration/multinodes.nim | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/integration/multinodes.nim b/tests/integration/multinodes.nim index f71bc218..c54a0a49 100644 --- a/tests/integration/multinodes.nim +++ b/tests/integration/multinodes.nim @@ -83,7 +83,7 @@ template multinodesuite*(name: string, body: untyped) = # ... let jsonRpcProviderUrl = "http://127.0.0.1:8545" var running {.inject, used.}: seq[RunningNode] - var bootstrap: string + var bootstrapNodes: seq[string] let starttime = now().format("yyyy-MM-dd'_'HH:mm:ss") var currentTestName = "" var nodeConfigs: NodeConfigs @@ -162,8 +162,8 @@ template multinodesuite*(name: string, body: untyped) = let updatedLogFile = getLogFile(role, some roleIdx) config.withLogFile(updatedLogFile) - if bootstrap.len > 0: - config.addCliOption("--bootstrap-node", bootstrap) + for bootstrapNode in bootstrapNodes: + config.addCliOption("--bootstrap-node", bootstrapNode) config.addCliOption("--api-port", $ await nextFreePort(8080 + nodeIdx)) config.addCliOption("--data-dir", datadir) config.addCliOption("--nat", "127.0.0.1") @@ -273,6 +273,13 @@ template multinodesuite*(name: string, body: untyped) = fail() quit(1) + proc updateBootstrapNodes(node: CodexProcess) = + without ninfo =? node.client.info(): + # raise CatchableError instead of Defect (with .get or !) so we + # can gracefully shutdown and prevent zombies + raiseMultiNodeSuiteError "Failed to get node info" + bootstrapNodes.add ninfo["spr"].getStr() + setup: if var conf =? nodeConfigs.hardhat: try: @@ -311,12 +318,7 @@ template multinodesuite*(name: string, body: untyped) = role: Role.Client, node: node ) - if running.len == 1: - without ninfo =? CodexProcess(node).client.info(): - # raise CatchableError instead of Defect (with .get or !) so we - # can gracefully shutdown and prevent zombies - raiseMultiNodeSuiteError "Failed to get node info" - bootstrap = ninfo["spr"].getStr() + CodexProcess(node).updateBootstrapNodes() if var providers =? nodeConfigs.providers: failAndTeardownOnError "failed to start provider nodes": @@ -326,6 +328,7 @@ template multinodesuite*(name: string, body: untyped) = role: Role.Provider, node: node ) + CodexProcess(node).updateBootstrapNodes() if var validators =? nodeConfigs.validators: failAndTeardownOnError "failed to start validator nodes":