Skip to content

Commit

Permalink
Add auth port
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Mar 1, 2022
1 parent 540337a commit c2d7677
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions testing/execution_engine_integration/src/execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use unused_port::unused_tcp_port;
/// Defined for each EE type (e.g., Geth, Nethermind, etc).
pub trait GenericExecutionEngine: Clone {
fn init_datadir() -> TempDir;
fn start_client(datadir: &TempDir, http_port: u16) -> Child;
fn start_client(datadir: &TempDir, http_port: u16, http_auth_port: u16) -> Child;
}

/// Holds handle to a running EE process, plus some other metadata.
Expand All @@ -19,6 +19,7 @@ pub struct ExecutionEngine<E> {
#[allow(dead_code)]
datadir: TempDir,
http_port: u16,
http_auth_port: u16,
child: Child,
}

Expand All @@ -35,18 +36,25 @@ impl<E: GenericExecutionEngine> ExecutionEngine<E> {
pub fn new(engine: E) -> Self {
let datadir = E::init_datadir();
let http_port = unused_tcp_port().unwrap();
let child = E::start_client(&datadir, http_port);
let http_auth_port = unused_tcp_port().unwrap();
let child = E::start_client(&datadir, http_port, http_auth_port);
Self {
engine,
datadir,
http_port,
http_auth_port,
child,
}
}

pub fn http_url(&self) -> SensitiveUrl {
SensitiveUrl::parse(&format!("http://127.0.0.1:{}", self.http_port)).unwrap()
}

#[allow(dead_code)] // Future use.
pub fn http_ath_url(&self) -> SensitiveUrl {
SensitiveUrl::parse(&format!("http://127.0.0.1:{}", self.http_auth_port)).unwrap()
}
}

/*
Expand Down Expand Up @@ -90,7 +98,7 @@ impl GenericExecutionEngine for Geth {
datadir
}

fn start_client(datadir: &TempDir, http_port: u16) -> Child {
fn start_client(datadir: &TempDir, http_port: u16, http_auth_port: u16) -> Child {
let network_port = unused_tcp_port().unwrap();

Command::new(Self::binary_path())
Expand All @@ -101,6 +109,8 @@ impl GenericExecutionEngine for Geth {
.arg("engine,eth")
.arg("--http.port")
.arg(http_port.to_string())
.arg("--http.authport")
.arg(http_auth_port.to_string())
.arg("--port")
.arg(network_port.to_string())
.stdout(build_stdio())
Expand Down

0 comments on commit c2d7677

Please sign in to comment.