Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix port passing from node process #2336

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Changed
- Restrict which `cfg` attributes can be used ‒ [#2313](https://github.com/use-ink/ink/pull/2313)

## Fixed
- [E2E] Have port parsing handle comma-separated list ‒ [#2336](https://github.com/use-ink/ink/pull/2336)

## Version 5.1.0

This is the first ink! release outside of Parity. ink! was started at Parity and
Expand Down Expand Up @@ -37,7 +40,7 @@ to cross-contract calls, but can now execute cross-parachain calls.
We added a contract example that demonstrates the usage:
[`contract-xcm`](https://github.com/use-ink/ink-examples/tree/main/contract-xcm)

We also added a new page on our documentation website:
We also added a new page on our documentation website:
[https://use.ink/basics/xcm](https://use.ink/basics/xcm).

You can view the Rust docs of the two functions here:
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ sp-core = { workspace = true }
sp-keyring = { workspace = true }
sp-runtime = { workspace = true }
sp-weights = { workspace = true }
regex = "1.11.1"

[dev-dependencies]
# Required for the doctest of `MessageBuilder::call`
Expand Down
34 changes: 32 additions & 2 deletions crates/e2e/src/node_proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,17 @@
.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.
let port_str = line_end.trim_end_matches(|b: char| !b.is_ascii_digit());
// match the first group of digits
let re = regex::Regex::new(r"^\d+").expect("regex creation failed");
let port_capture = re
.captures(line_end)
.unwrap_or_else(|| panic!("unable to extract port from '{}'", line_end));

Check warning on line 219 in crates/e2e/src/node_proc.rs

View check run for this annotation

Codecov / codecov/patch

crates/e2e/src/node_proc.rs#L219

Added line #L219 was not covered by tests
assert!(
port_capture.len() == 1,
"captured more than one port from '{}'",
line_end
);
let port_str = &port_capture[0];

// expect to have a number here (the chars after '127.0.0.1:') and parse them
// into a u16.
Expand Down Expand Up @@ -269,4 +278,25 @@
assert!(res1.is_err());
assert!(res2.is_err());
}

#[test]
fn parse_port_from_node_output() {
let log = "2024-12-04 10:57:03.893 INFO main sc_rpc_server: Running JSON-RPC server: addr=127.0.0.1:9944,[::1]:9944 ";
let port = find_substrate_port_from_output(log.as_bytes());
assert_eq!(port, 9944);

let log = "2024-12-04 10:57:03.893 INFO main sc_rpc_server: Running JSON-RPC server: addr=127.0.0.1:9944 ";
let port = find_substrate_port_from_output(log.as_bytes());
assert_eq!(port, 9944);

let log = r#"2024-12-04 11:02:24.637 INFO main sc_cli::runner: 👤 Role: AUTHORITY
2024-12-04 11:02:24.637 INFO main sc_cli::runner: 💾 Database: RocksDb at /var/folders/s5/5gcp8ck95k39z006fj059_0c0000gn/T/substrateHZoRbb/chains/dev/db/full
2024-12-04 11:02:25.324 WARN main sc_service::config: Using default protocol ID "sup" because none is configured in the chain specs
2024-12-04 11:02:25.327 INFO main sc_rpc_server: Running JSON-RPC server: addr=127.0.0.1:9944,[::1]:9944
2024-12-04 11:02:24.637 INFO main sc_cli::runner: 💾 Database: RocksDb at /var/folders/s5/5gcp8ck95k39z006fj059_0c0000gn/T/substrateHZoRbb/chains/dev/db/full
2024-12-04 11:02:24.637 INFO main sc_cli::runner: 💾 Database: RocksDb at /var/folders/s5/5gcp8ck95k39z006fj059_0c0000gn/T/substrateHZoRbb/chains/dev/db/full
"#;
let port = find_substrate_port_from_output(log.as_bytes());
assert_eq!(port, 9944);
}
}
Loading