Skip to content

Commit

Permalink
use socket for ip port pair
Browse files Browse the repository at this point in the history
  • Loading branch information
rnbguy committed Nov 20, 2024
1 parent 9136faf commit 34eded9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/tests/network/anvil.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::net::Ipv4Addr;
use core::net::SocketAddr;
use testresult::TestResult;

use alloy::node_bindings::{Anvil, AnvilInstance};
Expand Down Expand Up @@ -44,8 +45,8 @@ impl EthereumNetwork for AnvilPoA {

fn network_config(&self) -> EthereumConfig {
EthereumConfig {
ip: Ipv4Addr::UNSPECIFIED.into(),
port: self.port,
el_socket: SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), self.port),
cl_socket: None,
mnemonics: vec![self.mnemonic.clone()],
block_time: self.block_time,
}
Expand Down
4 changes: 2 additions & 2 deletions src/tests/network/ethpkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ impl EthereumNetwork for EthPkgKurtosis {

fn network_config(&self) -> EthereumConfig {
EthereumConfig {
ip: self.el_socket.unwrap().ip(),
port: self.el_socket.unwrap().port(),
el_socket: self.el_socket.unwrap(),
cl_socket: self.cl_socket,
mnemonics: vec!["giant issue aisle success illegal bike spike question tent bar rely arctic volcano long crawl hungry vocal artwork sniff fantasy very lucky have athlete".into()],
block_time: self.block_time,
}
Expand Down
10 changes: 5 additions & 5 deletions src/tests/network/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use alloy::providers::{Provider, ProviderBuilder};
use core::future::Future;
use core::marker::Sync;
use core::net::IpAddr;
use core::net::SocketAddr;
use testresult::TestResult;

pub mod anvil;
pub mod ethpkg;

pub struct EthereumConfig {
pub ip: IpAddr,
pub port: u16,
pub el_socket: SocketAddr,
pub cl_socket: Option<SocketAddr>,
pub mnemonics: Vec<String>,
pub block_time: u64,
}
Expand All @@ -21,10 +21,10 @@ pub trait EthereumNetwork: Sync + Send + Sized {

fn health_check(&self) -> impl Future<Output = TestResult> + Send {
async {
let EthereumConfig { ip, port, .. } = self.network_config();
let EthereumConfig { el_socket, .. } = self.network_config();
let provider = ProviderBuilder::new()
.with_recommended_fillers()
.on_builtin(&format!("http://{}:{}", ip, port))
.on_builtin(&format!("http://{}", el_socket))
.await?;
provider.get_chain_id().await?;
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions src/tests/scenario/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ pub struct ERC20Transfer;
impl Scenario for ERC20Transfer {
async fn run(&self, config: EthereumConfig) -> TestResult {
let EthereumConfig {
ip,
port,
el_socket,
mnemonics,
block_time,
..
} = config;

let url = format!("http://{}:{}", ip, port).to_string();
let url = format!("http://{}", el_socket).to_string();

let mnemonic = &mnemonics[0];

Expand Down

0 comments on commit 34eded9

Please sign in to comment.