Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- [E2E] Allow testing with live-chain state - [#1949](https://github.com/paritytech/ink/pull/1949)
- [E2E] Call builders and extra gas margin option - [#1917](https://github.com/paritytech/ink/pull/1917)
- Make `set_code_hash` generic - [#1906](https://github.com/paritytech/ink/pull/1906)
- Clean E2E configuration parsing - [#1922](https://github.com/paritytech/ink/pull/1922)
Expand Down
1 change: 1 addition & 0 deletions crates/e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ scale-info = { workspace = true, features = ["derive"] }
[features]
default = ["std"]
std = []
live-state-test = ["subxt/unstable-light-client"]
drink = [
"dep:drink",
"subxt-metadata",
Expand Down
27 changes: 15 additions & 12 deletions crates/e2e/src/node_proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,20 @@ where
e
)
})?;

// Wait for RPC port to be logged (it's logged to stderr):
let stderr = proc.stderr.take().unwrap();
let port = find_substrate_port_from_output(stderr);
let url = format!("ws://127.0.0.1:{port}");
// Wait for RPC port to be logged (it's logged to stderr):
let port_str: String = match option_env!("WS_PORT") {
Some(v) => v.to_string(),
None => {
// expect to have a number here (the chars after '127.0.0.1:').
find_substrate_port_from_output(stderr)
}
};

let ws_port: u16 = port_str
.parse()
.unwrap_or_else(|_| panic!("valid port number expected, got '{port_str}'"));
let url = format!("ws://127.0.0.1:{ws_port}");

// Connect to the node with a `subxt` client:
let rpc = RpcClient::from_url(url.clone())
Expand Down Expand Up @@ -195,7 +204,7 @@ where

// Consume a stderr reader from a spawned substrate command and
// locate the port number that is logged out to it.
fn find_substrate_port_from_output(r: impl Read + Send + 'static) -> u16 {
fn find_substrate_port_from_output(r: impl Read + Send + 'static) -> String {
BufReader::new(r)
.lines()
.find_map(|line| {
Expand All @@ -215,13 +224,7 @@ fn find_substrate_port_from_output(r: impl Read + Send + 'static) -> u16 {
// 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());

// 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 tracing line, got '{port_str}'")
});

Some(port_num)
Some(port_str.to_string())
})
.expect("We should find a port before the reader ends")
}
Expand Down
3 changes: 1 addition & 2 deletions integration-tests/e2e-call-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ publish = false
ink = { path = "../../crates/ink", default-features = false }

[dev-dependencies]
ink_e2e = { path = "../../crates/e2e" }
subxt = { version = "0.32.1", default-features = false }
ink_e2e = { path = "../../crates/e2e", features = ["live-state-test"]}

[lib]
path = "lib.rs"
Expand Down