Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
avoid polluting the default geth directory
Browse files Browse the repository at this point in the history
 * this caused test failures for other tests which used geth on the
   default directory and the mainnet chain id
  • Loading branch information
Rjected committed Nov 29, 2022
1 parent dbb53a9 commit a6e740a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ethers-core/src/utils/geth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{unused_port, Genesis};
use crate::types::H256;
use std::{
env::temp_dir,
fs::File,
fs::{create_dir, File},
io::{BufRead, BufReader},
path::PathBuf,
process::{Child, Command, Stdio},
Expand Down Expand Up @@ -324,6 +324,11 @@ impl Geth {

if let Some(ref data_dir) = self.data_dir {
cmd.arg("--datadir").arg(data_dir);

// create the directory if it doesn't exist
if !data_dir.exists() {
create_dir(data_dir).expect("could not create data dir");
}
}

// Dev mode with custom block time
Expand Down
3 changes: 2 additions & 1 deletion ethers-providers/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2176,13 +2176,14 @@ mod tests {
let p2p_listener_port = 13337u16;
let authrpc_port = 8551u16;
let network = 1337u64;
let temp_dir = tempfile::tempdir().unwrap().into_path();

let (geth, provider) = spawn_geth_and_create_provider(
network,
port,
p2p_listener_port,
authrpc_port,
None,
Some(temp_dir),
None,
);

Expand Down

0 comments on commit a6e740a

Please sign in to comment.