use communitas_core::test_harness::TestHarness;
use std::time::Duration;
#[tokio::test]
#[ignore] async fn test_read_write_bootstrap_nodes() {
let harness = TestHarness::new(3).await.expect("harness creation failed");
let addrs = harness.get_bootstrap_addrs().await;
assert_eq!(addrs.len(), 3, "Should have 3 bootstrap addresses");
harness.cleanup().await.expect("cleanup failed");
}
#[tokio::test]
#[ignore] async fn test_bootstrap_connection() {
let harness = TestHarness::new(3).await.expect("harness creation failed");
let _bootstrap_addrs = [harness
.get_node(0)
.await
.expect("node 0 not found")
.read()
.await
.bootstrap_addr()];
harness
.wait_until_connected(3, Duration::from_secs(10))
.await
.expect("bootstrap connection failed");
harness.cleanup().await.expect("cleanup failed");
}
#[tokio::test]
#[ignore] async fn test_multiple_bootstrap_nodes() {
let harness = TestHarness::new(4).await.expect("harness creation failed");
let bootstrap_addrs = harness.get_bootstrap_addrs().await;
let _bootstrap_list = [bootstrap_addrs[0].clone(), bootstrap_addrs[1].clone()];
harness
.partition(&[0], &[2, 3])
.await
.expect("partition failed");
tokio::time::sleep(Duration::from_secs(2)).await;
{
let network = harness.network.read().await;
assert!(
network.are_connected(1, 2).await,
"Should connect via backup bootstrap"
);
assert!(
network.are_connected(1, 3).await,
"Should connect via backup bootstrap"
);
}
harness.cleanup().await.expect("cleanup failed");
}
#[tokio::test]
#[ignore] async fn test_bootstrap_fallback_unreachable() {
let harness = TestHarness::new(1).await.expect("harness creation failed");
let _bad_bootstrap = ["192.0.2.1:9000".to_string()];
harness.cleanup().await.expect("cleanup failed");
}
#[tokio::test]
#[ignore] async fn test_bootstrap_timeout() {
let harness = TestHarness::new(2).await.expect("harness creation failed");
harness.set_latency(0, 1, 10000).await;
let start = std::time::Instant::now();
let _elapsed = start.elapsed();
harness.cleanup().await.expect("cleanup failed");
}
#[tokio::test]
#[ignore] async fn test_cold_start_empty_cache() {
let harness = TestHarness::new(1).await.expect("harness creation failed");
harness.cleanup().await.expect("cleanup failed");
}
#[tokio::test]
#[ignore] async fn test_empty_bootstrap_config() {
let harness = TestHarness::new(1).await.expect("harness creation failed");
let _empty_bootstrap: Vec<String> = vec![];
harness.cleanup().await.expect("cleanup failed");
}
#[tokio::test]
#[ignore] async fn test_ipv4_preferred_over_ipv6() {
}