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

(cherry picked from commit 6d7810e)
  • Loading branch information
varex83 authored and ascjones committed Aug 22, 2023
1 parent 868d31d commit 72fa7fc
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions crates/e2e/src/node_proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ where

/// Attempt to kill the running substrate process.
pub fn kill(&mut self) -> Result<(), String> {
log::info!("Killing node process {}", self.proc.id());
tracing::info!("Killing node process {}", self.proc.id());
if let Err(err) = self.proc.kill() {
let err = format!("Error killing node process {}: {}", self.proc.id(), err);
log::error!("{}", err);
tracing::error!("{}", err);
return Err(err)
}
Ok(())
Expand Down Expand Up @@ -135,22 +135,22 @@ 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}");
log::error!("{}", 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 @@ -176,6 +176,7 @@ fn find_substrate_port_from_output(r: impl Read + Send + 'static) -> u16 {
.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)?;

// trim non-numeric chars from the end of the port part of the line.
Expand All @@ -184,7 +185,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 72fa7fc

Please sign in to comment.