From 34eded9433f29188ca69daf57de5e80d3e1b086f Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Wed, 20 Nov 2024 15:06:39 +0100 Subject: [PATCH] use socket for ip port pair --- src/tests/network/anvil.rs | 5 +++-- src/tests/network/ethpkg.rs | 4 ++-- src/tests/network/mod.rs | 10 +++++----- src/tests/scenario/erc20.rs | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/tests/network/anvil.rs b/src/tests/network/anvil.rs index df2112e..e250c30 100644 --- a/src/tests/network/anvil.rs +++ b/src/tests/network/anvil.rs @@ -1,4 +1,5 @@ use core::net::Ipv4Addr; +use core::net::SocketAddr; use testresult::TestResult; use alloy::node_bindings::{Anvil, AnvilInstance}; @@ -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, } diff --git a/src/tests/network/ethpkg.rs b/src/tests/network/ethpkg.rs index e7ef92a..131d95e 100644 --- a/src/tests/network/ethpkg.rs +++ b/src/tests/network/ethpkg.rs @@ -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, } diff --git a/src/tests/network/mod.rs b/src/tests/network/mod.rs index f49b496..460b8d5 100644 --- a/src/tests/network/mod.rs +++ b/src/tests/network/mod.rs @@ -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, pub mnemonics: Vec, pub block_time: u64, } @@ -21,10 +21,10 @@ pub trait EthereumNetwork: Sync + Send + Sized { fn health_check(&self) -> impl Future + 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(()) diff --git a/src/tests/scenario/erc20.rs b/src/tests/scenario/erc20.rs index 2727a73..eb4def0 100644 --- a/src/tests/scenario/erc20.rs +++ b/src/tests/scenario/erc20.rs @@ -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];