feat(core): add ability to take geth stderr (#2010)

* makes the geth logs accessible by using take() on the GethInstance
   stderr
This commit is contained in:
Dan Cline 2023-01-04 16:31:48 -05:00 committed by GitHub
parent 5f2476510b
commit 9147ee8e63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -5,7 +5,7 @@ use std::{
fs::{create_dir, File},
io::{BufRead, BufReader},
path::PathBuf,
process::{Child, Command, Stdio},
process::{Child, ChildStderr, Command, Stdio},
time::{Duration, Instant},
};
@ -76,7 +76,17 @@ impl GethInstance {
&self.data_dir
}
/// Takes the stderr contained in the child process.
///
/// This leaves a `None` in its place, so calling methods that require a stderr to be present
/// will fail if called after this.
pub fn stderr(&mut self) -> Result<ChildStderr, GethInstanceError> {
self.pid.stderr.take().ok_or(GethInstanceError::NoStderr)
}
/// Blocks until geth adds the specified peer, using 20s as the timeout.
///
/// Requires the stderr to be present in the `GethInstance`.
pub fn wait_to_add_peer(&mut self, id: H256) -> Result<(), GethInstanceError> {
let mut stderr = self.pid.stderr.as_mut().ok_or(GethInstanceError::NoStderr)?;
let mut err_reader = BufReader::new(&mut stderr);