Skip to content
11 changes: 6 additions & 5 deletions packages/layer-tests/src/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ async fn _run(
let cosmos_code_map = CosmosCodeMap::new(DashMap::new());

// Create test registry from test mode
let registry = test_registry::TestRegistry::from_test_mode(
let (registry, hypercore_clients) = test_registry::TestRegistry::from_test_mode(
mode,
configs.chains.clone(),
&clients,
&cosmos_code_map,
// configs
// .wavs_configs
// .first()
// .and_then(|config| config.hyperswarm_bootstrap.clone()),
configs
.wavs_configs
.first()
.and_then(|config| config.hyperswarm_bootstrap.clone()),
)
.await;

Expand Down Expand Up @@ -183,6 +183,7 @@ async fn _run(
clients,
registry,
component_sources,
hypercore_clients,
service_managers,
cosmos_code_map,
report.clone(),
Expand Down
75 changes: 35 additions & 40 deletions packages/layer-tests/src/e2e/handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod cosmos;
mod evm;
pub mod hypercore;

use std::{collections::HashMap, sync::Arc, time::Duration};
use std::{collections::HashMap, net::SocketAddr, sync::Arc, time::Duration};

use cosmos::CosmosInstance;
use evm::EvmInstance;
Expand All @@ -21,10 +21,10 @@ use wavs_types::{ChainKey, ChainKeyNamespace};

use crate::config::TestP2pMode;

/// Default port for the hyperswarm bootstrap node
//const HYPERSWARM_BOOTSTRAP_PORT: u16 = 49737;
/// Port for the hyperswarm bootstrap node (0 = OS-assigned to avoid conflicts in CI)
const HYPERSWARM_BOOTSTRAP_PORT: u16 = 0;
use super::config::Configs;
//use super::matrix::EvmService;
use super::matrix::EvmService;

pub struct AppHandles {
/// One handle per WAVS operator instance
Expand All @@ -44,15 +44,11 @@ impl AppHandles {
Option<std::net::SocketAddr>,
Option<async_std::task::JoinHandle<std::io::Result<()>>>,
) = {
// #[cfg(feature = "hypercore-tests")]
// {
// if configs.matrix.evm.contains(&EvmService::HypercoreEchoData) {
// Self::start_hyperswarm_bootstrap()
// } else {
// (None, None)
// }
// }
(None, None)
if configs.matrix.evm.contains(&EvmService::HypercoreEchoData) {
Self::start_hyperswarm_bootstrap()
} else {
(None, None)
}
};
if let Some(addr) = bootstrap_addr {
let addr = addr.to_string();
Expand Down Expand Up @@ -280,31 +276,30 @@ impl AppHandles {
Ok(handles)
}

// fn start_hyperswarm_bootstrap() -> (
// Option<SocketAddr>,
// Option<async_std::task::JoinHandle<std::io::Result<()>>>,
// ) {
// let bind_addr = SocketAddr::new(
// std::net::IpAddr::V4(std::net::Ipv4Addr::new(127, 0, 0, 1)),
// HYPERSWARM_BOOTSTRAP_PORT,
// );

// match async_std::task::block_on(hyperswarm::run_bootstrap_node(Some(bind_addr))) {
// Ok((addr, handle)) => {
// tracing::info!(
// "Bootstrap node bound to {}, listening for peer connections",
// addr
// );

// // Give the bootstrap node time to bind and initialize its DHT
// std::thread::sleep(Duration::from_secs(5));

// (Some(addr), Some(handle))
// }
// Err(err) => {
// tracing::warn!("Failed to start hyperswarm bootstrap node: {err}");
// (None, None)
// }
// }
// }
fn start_hyperswarm_bootstrap() -> (
Option<SocketAddr>,
Option<async_std::task::JoinHandle<std::io::Result<()>>>,
) {
let bind_addr = SocketAddr::new(
std::net::IpAddr::V4(std::net::Ipv4Addr::new(127, 0, 0, 1)),
HYPERSWARM_BOOTSTRAP_PORT,
);

match async_std::task::block_on(hyperswarm::run_bootstrap_node(Some(bind_addr))) {
Ok((addr, handle)) => {
tracing::info!(
"Bootstrap node bound to {}, listening for peer connections",
addr
);

// Give the bootstrap node time to bind and initialize its DHT
std::thread::sleep(Duration::from_secs(5));

(Some(addr), Some(handle))
}
Err(err) => {
panic!("Failed to start hyperswarm bootstrap node: {err}. All hypercore tests will fail without a bootstrap node.");
}
}
}
}
Loading
Loading