From 6e0145168421383152f4ed6a6a72a708a0eb01e4 Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Thu, 29 Aug 2024 17:39:32 +0200 Subject: [PATCH] fix: substrate-runner support several rpc endpoints (#1736) * fix: support several rpc endpoints in substrate Close #1735 * Update testing/substrate-runner/src/lib.rs * Update testing/substrate-runner/src/lib.rs * fix grumbles * Update testing/substrate-runner/src/lib.rs --- testing/substrate-runner/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/testing/substrate-runner/src/lib.rs b/testing/substrate-runner/src/lib.rs index eb2e6064b6..790d3d6861 100644 --- a/testing/substrate-runner/src/lib.rs +++ b/testing/substrate-runner/src/lib.rs @@ -197,9 +197,10 @@ fn try_find_substrate_port_from_output( .or_else(|| line.rsplit_once("Running JSON-RPC server: addr=127.0.0.1:")) .map(|(_, port_str)| port_str); - if let Some(line_port) = line_port { - // trim non-numeric chars from the end of the port part of the line. - let port_str = line_port.trim_end_matches(|b: char| !b.is_ascii_digit()); + if let Some(ports) = line_port { + // If more than one rpc server is started the log will capture multiple ports + // such as `addr=127.0.0.1:9944,[::1]:9944` + let port_str: String = ports.chars().take_while(|c| c.is_numeric()).collect(); // expect to have a number here (the chars after '127.0.0.1:') and parse them into a u16. let port_num = port_str