Skip to content

Commit

Permalink
ink-e2e Test Failures in substrate-contracts-node (v0.27.0) due to Un…
Browse files Browse the repository at this point in the history
…supported --ws-port Argument (#1850)

* Update ink-e2e to the latest substrate-contracts-node

* Apply rust-fmt

* Change logging, to be up-to-date with master branch

* Apply rustfmt-nightly
  • Loading branch information
varex83 authored Jul 19, 2023
1 parent 0749aa6 commit 6d7810e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions crates/e2e/src/node_proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,21 @@ where

// Wait for RPC port to be logged (it's logged to stderr):
let stderr = proc.stderr.take().unwrap();
let ws_port = find_substrate_port_from_output(stderr);
let ws_url = format!("ws://127.0.0.1:{ws_port}");
let port = find_substrate_port_from_output(stderr);
let url = format!("ws://127.0.0.1:{port}");

// Connect to the node with a `subxt` client:
let client = OnlineClient::from_url(ws_url.clone()).await;
let client = OnlineClient::from_url(url.clone()).await;
match client {
Ok(client) => {
Ok(TestNodeProcess {
proc,
client,
url: ws_url.clone(),
url: url.clone(),
})
}
Err(err) => {
let err = format!("Failed to connect to node rpc at {ws_url}: {err}");
let err = format!("Failed to connect to node rpc at {url}: {err}");
tracing::error!("{}", err);
proc.kill().map_err(|e| {
format!("Error killing substrate process '{}': {}", proc.id(), e)
Expand All @@ -172,6 +172,9 @@ fn find_substrate_port_from_output(r: impl Read + Send + 'static) -> u16 {
// substrate).
let line_end = line
.rsplit_once("Listening for new connections on 127.0.0.1:")
.or_else(|| {
line.rsplit_once("Running JSON-RPC WS server: addr=127.0.0.1:")
})
.or_else(|| line.rsplit_once("Running JSON-RPC server: addr=127.0.0.1:"))
.map(|(_, port_str)| port_str)?;

Expand All @@ -181,7 +184,7 @@ fn find_substrate_port_from_output(r: impl Read + Send + 'static) -> u16 {
// expect to have a number here (the chars after '127.0.0.1:') and parse them
// into a u16.
let port_num = port_str.parse().unwrap_or_else(|_| {
panic!("valid port expected for log line, got '{port_str}'")
panic!("valid port expected for tracing line, got '{port_str}'")
});

Some(port_num)
Expand Down

0 comments on commit 6d7810e

Please sign in to comment.