diff --git a/crates/node/src/geth.rs b/crates/node/src/geth.rs index 4866d29..7000633 100644 --- a/crates/node/src/geth.rs +++ b/crates/node/src/geth.rs @@ -207,6 +207,18 @@ impl Node for Instance { _ => anyhow::bail!("expected a diff mode trace"), } } + + fn version(&self) -> anyhow::Result { + let output = Command::new(&self.geth) + .arg("--version") + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::null()) + .spawn()? + .wait_with_output()? + .stdout; + Ok(String::from_utf8_lossy(&output).into()) + } } impl Drop for Instance { @@ -252,4 +264,13 @@ mod tests { .spawn(GENESIS_JSON.to_string()) .unwrap(); } + + #[test] + fn version_works() { + let version = Instance::new(&test_config().0).unwrap().version().unwrap(); + assert!( + version.starts_with("geth version"), + "expected version string, got: '{version}'" + ); + } } diff --git a/crates/node/src/lib.rs b/crates/node/src/lib.rs index ca52c04..a98e995 100644 --- a/crates/node/src/lib.rs +++ b/crates/node/src/lib.rs @@ -25,4 +25,7 @@ pub trait Node: EthereumNode { /// Returns the state diff of the transaction hash in the [TransactionReceipt]. fn state_diff(&self, transaction: TransactionReceipt) -> anyhow::Result; + + /// Returns the node version. + fn version(&self) -> anyhow::Result; }