the geth version

Signed-off-by: xermicus <bigcyrill@hotmail.com>
This commit is contained in:
xermicus
2025-03-24 09:42:51 +01:00
parent 33c5adbc22
commit 9bba37b7a9
2 changed files with 24 additions and 0 deletions
+21
View File
@@ -207,6 +207,18 @@ impl Node for Instance {
_ => anyhow::bail!("expected a diff mode trace"),
}
}
fn version(&self) -> anyhow::Result<String> {
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}'"
);
}
}
+3
View File
@@ -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<DiffMode>;
/// Returns the node version.
fn version(&self) -> anyhow::Result<String>;
}