diff --git a/crates/core/tests/connectivity.rs b/crates/core/tests/connectivity.rs index befa470c3..7b2d6d61b 100644 --- a/crates/core/tests/connectivity.rs +++ b/crates/core/tests/connectivity.rs @@ -23,7 +23,6 @@ fn fixed_three_node_locations() -> Vec { /// connecting to the gateway. #[freenet_test( nodes = ["gateway", "peer"], - auto_connect_peers = true, timeout_secs = 180, startup_wait_secs = 15, aggregate_events = "always", @@ -256,7 +255,6 @@ async fn test_basic_gateway_connectivity(ctx: &mut TestContext) -> TestResult { /// #[freenet_test( nodes = ["gateway", "peer1", "peer2"], - auto_connect_peers = true, timeout_secs = 180, startup_wait_secs = 30, node_locations_fn = fixed_three_node_locations, @@ -541,7 +539,6 @@ async fn perform_put_with_retries( /// when promoting transients. #[freenet_test( nodes = ["gateway", "peer"], - auto_connect_peers = true, timeout_secs = 60, startup_wait_secs = 15, aggregate_events = "always", diff --git a/crates/core/tests/operations.rs b/crates/core/tests/operations.rs index 7018577bc..70d670c68 100644 --- a/crates/core/tests/operations.rs +++ b/crates/core/tests/operations.rs @@ -216,7 +216,6 @@ async fn send_put_with_retry( /// Test PUT operation across two peers (gateway and peer) #[freenet_test( nodes = ["gateway", "peer-a"], - auto_connect_peers = true, timeout_secs = 180, startup_wait_secs = 15, tokio_flavor = "multi_thread", @@ -324,7 +323,6 @@ async fn test_put_contract(ctx: &mut TestContext) -> TestResult { #[freenet_test( nodes = ["gateway", "peer-a"], - auto_connect_peers = true, timeout_secs = 180, startup_wait_secs = 20, tokio_flavor = "multi_thread", @@ -495,7 +493,6 @@ async fn test_update_contract(ctx: &mut TestContext) -> TestResult { /// This is a regression test for issue #1995. #[freenet_test( nodes = ["gateway", "peer-a"], - auto_connect_peers = true, timeout_secs = 180, startup_wait_secs = 15, tokio_flavor = "multi_thread", @@ -646,7 +643,6 @@ async fn test_put_merge_persists_state(ctx: &mut TestContext) -> TestResult { #[ignore] #[freenet_test( nodes = ["gateway", "node-a", "node-b"], - auto_connect_peers = true, timeout_secs = 600, startup_wait_secs = 40, tokio_flavor = "multi_thread", @@ -1220,7 +1216,6 @@ async fn test_multiple_clients_subscription(ctx: &mut TestContext) -> TestResult #[freenet_test( nodes = ["gateway", "node-a"], - auto_connect_peers = true, timeout_secs = 120, startup_wait_secs = 20, tokio_flavor = "multi_thread", @@ -1448,7 +1443,6 @@ async fn test_get_with_subscribe_flag(ctx: &mut TestContext) -> TestResult { // FIXME Update notification is not received #[freenet_test( nodes = ["gateway", "node-a"], - auto_connect_peers = true, timeout_secs = 180, startup_wait_secs = 20, tokio_flavor = "multi_thread", @@ -1738,7 +1732,6 @@ async fn test_put_with_subscribe_flag(ctx: &mut TestContext) -> TestResult { #[freenet_test( nodes = ["gateway", "client-node"], - auto_connect_peers = true, timeout_secs = 180, startup_wait_secs = 20, tokio_flavor = "multi_thread", @@ -1936,7 +1929,6 @@ fn expected_three_hop_locations() -> [f64; 3] { "peer-a": { location: three_hop_peer_a_location() }, "peer-c": { location: three_hop_peer_c_location() }, }, - auto_connect_peers = true, timeout_secs = 240, startup_wait_secs = 15, aggregate_events = "on_failure", @@ -2531,7 +2523,6 @@ async fn wait_for_subscribe_response( #[freenet_test( nodes = ["gateway", "peer-node"], - auto_connect_peers = true, timeout_secs = 180, startup_wait_secs = 10, tokio_flavor = "multi_thread", @@ -2605,7 +2596,6 @@ async fn test_subscription_introspection(ctx: &mut TestContext) -> TestResult { #[freenet_test( nodes = ["gateway", "peer-a"], - auto_connect_peers = true, timeout_secs = 180, startup_wait_secs = 20, tokio_flavor = "multi_thread", diff --git a/crates/core/tests/test_macro_example.rs b/crates/core/tests/test_macro_example.rs index 8d81c4336..61dafe68d 100644 --- a/crates/core/tests/test_macro_example.rs +++ b/crates/core/tests/test_macro_example.rs @@ -209,15 +209,14 @@ async fn test_multiple_gateways(ctx: &mut TestContext) -> TestResult { Ok(()) } -/// Test with auto_connect_peers enabled +/// Test with auto_connect_peers enabled (now the default) #[freenet_test( nodes = ["gateway", "peer-1", "peer-2"], - auto_connect_peers = true, timeout_secs = 120, startup_wait_secs = 15 )] async fn test_auto_connect_peers(ctx: &mut TestContext) -> TestResult { - // With auto_connect_peers=true, all peer nodes are configured to + // With auto_connect_peers=true (now default), all peer nodes are configured to // connect to all gateway nodes automatically let gateway = ctx.gateway()?; @@ -238,16 +237,15 @@ async fn test_auto_connect_peers(ctx: &mut TestContext) -> TestResult { Ok(()) } -/// Test with multiple gateways and auto_connect_peers +/// Test with multiple gateways and auto_connect_peers (now the default) #[freenet_test( nodes = ["gw-1", "gw-2", "peer-1", "peer-2"], gateways = ["gw-1", "gw-2"], - auto_connect_peers = true, timeout_secs = 120, startup_wait_secs = 15 )] async fn test_multi_gateway_auto_connect(ctx: &mut TestContext) -> TestResult { - // With auto_connect_peers=true and multiple gateways, + // With auto_connect_peers=true (now default) and multiple gateways, // all peer nodes are configured to connect to ALL gateway nodes let gateways = ctx.gateways(); diff --git a/crates/freenet-macros/README.md b/crates/freenet-macros/README.md index 9e81de254..271bf8a70 100644 --- a/crates/freenet-macros/README.md +++ b/crates/freenet-macros/README.md @@ -29,19 +29,18 @@ async fn test_basic_gateway(ctx: &mut TestContext) -> TestResult { } ``` -### Multi-Node Test with Auto-Connect +### Multi-Node Test ```rust #[freenet_test( nodes = ["gateway", "peer-1", "peer-2"], - auto_connect_peers = true, aggregate_events = "on_failure" )] async fn test_network_operations(ctx: &mut TestContext) -> TestResult { let gateway = ctx.gateway()?; let peers = ctx.peers(); - // All peers are automatically configured to connect to the gateway + // All peers automatically connect to the gateway (default behavior) assert_eq!(peers.len(), 2); // Your test logic here... @@ -88,8 +87,7 @@ Set explicit ring locations for nodes (order must match the `nodes` list). This ```rust #[freenet_test( nodes = ["gateway", "peer-a", "peer-b"], - node_locations = [0.2, 0.6, 0.85], // gateway, peer-a, peer-b - auto_connect_peers = true + node_locations = [0.2, 0.6, 0.85] // gateway, peer-a, peer-b )] async fn test_with_locations(ctx: &mut TestContext) -> TestResult { // Test logic here... @@ -113,8 +111,7 @@ fn my_locations() -> Vec { #[freenet_test( nodes = ["gateway", "peer-a", "peer-b"], - node_locations_fn = my_locations, - auto_connect_peers = true + node_locations_fn = my_locations )] ``` @@ -147,18 +144,22 @@ async fn test_with_node_configs(ctx: &mut TestContext) -> TestResult { #### `auto_connect_peers` Automatically configure all peer nodes to connect to all gateway nodes. +**Behavior:** +- When `true` (default): Peers are pre-configured with gateway connection info +- When `false`: You must manually configure peer connections +- Works with multiple gateways (peers connect to all gateways) + ```rust +// Default behavior - peers auto-connect to gateways +#[freenet_test(nodes = ["gateway", "peer-1", "peer-2"])] + +// Disable auto-connect for manual connection setup #[freenet_test( nodes = ["gateway", "peer-1", "peer-2"], - auto_connect_peers = true // Peers auto-connect to gateway + auto_connect_peers = false )] ``` -**Behavior:** -- When `true`: Peers are pre-configured with gateway connection info -- When `false` (default): You must manually configure peer connections -- Works with multiple gateways (peers connect to all gateways) - #### `aggregate_events` Control when event aggregation reports are generated. @@ -324,7 +325,6 @@ use freenet_stdlib::prelude::*; #[freenet_test( nodes = ["gateway", "peer-1", "peer-2"], - auto_connect_peers = true, timeout_secs = 180, startup_wait_secs = 15, aggregate_events = "on_failure", @@ -474,7 +474,6 @@ EVENT LOG SUMMARY #[freenet_test( nodes = ["gw-1", "gw-2", "peer-1", "peer-2", "peer-3", "peer-4"], gateways = ["gw-1", "gw-2"], - auto_connect_peers = true, startup_wait_secs = 20 // More time for connections to establish )] ``` @@ -561,9 +560,10 @@ Each approach has significant trade-offs. Using `Result`-based errors is the idi **Problem:** Peers don't connect to gateway **Solutions:** -1. Use `auto_connect_peers = true` to handle connection setup automatically -2. Increase `startup_wait_secs` to allow more time for connections -3. Check gateway network port is set correctly +1. `auto_connect_peers` is `true` by default, so connection setup is automatic +2. If using `auto_connect_peers = false`, ensure manual connection setup is correct +3. Increase `startup_wait_secs` to allow more time for connections +4. Check gateway network port is set correctly ### Multi-Gateway Tests Fail diff --git a/crates/freenet-macros/src/lib.rs b/crates/freenet-macros/src/lib.rs index 988b3c38e..6d0fc5475 100644 --- a/crates/freenet-macros/src/lib.rs +++ b/crates/freenet-macros/src/lib.rs @@ -45,7 +45,7 @@ use parser::FreenetTestArgs; /// /// - `nodes` (required): Array of node labels /// - `gateways` (optional): Array of nodes that should be gateways. If not specified, the first node is a gateway. -/// - `auto_connect_peers` (optional): If true, peer nodes are configured to connect to all gateway nodes (default: false) +/// - `auto_connect_peers` (optional): If true, peer nodes are configured to connect to all gateway nodes (default: true) /// - `timeout_secs` (optional): Test timeout in seconds (default: 180) /// - `startup_wait_secs` (optional): Node startup wait in seconds (default: 15) /// - `aggregate_events` (optional): When to aggregate events: @@ -86,18 +86,18 @@ use parser::FreenetTestArgs; /// } /// ``` /// -/// ## Auto-Connect Peers to Gateways +/// ## Disabling Auto-Connect (peers connect to gateways by default) /// ```ignore /// #[freenet_test( /// nodes = ["gateway", "peer-1", "peer-2"], -/// auto_connect_peers = true, // Peers will connect to gateway +/// auto_connect_peers = false, // Disable automatic peer-to-gateway connections /// timeout_secs = 120 /// )] -/// async fn test_with_connections(ctx: &mut TestContext) -> TestResult { -/// // Peers are configured to discover and connect to the gateway +/// async fn test_manual_connections(ctx: &mut TestContext) -> TestResult { +/// // Peers must manually discover and connect to the gateway /// let gateway = ctx.gateway()?; /// let peers = ctx.peers(); -/// // Test peer-gateway interactions... +/// // Set up manual connections... /// Ok(()) /// } /// ``` diff --git a/crates/freenet-macros/src/parser.rs b/crates/freenet-macros/src/parser.rs index e16ba5183..dae18b23f 100644 --- a/crates/freenet-macros/src/parser.rs +++ b/crates/freenet-macros/src/parser.rs @@ -50,7 +50,7 @@ impl syn::parse::Parse for FreenetTestArgs { let mut gateways = None; let mut node_locations = None; let mut node_locations_fn = None; - let mut auto_connect_peers = false; + let mut auto_connect_peers = true; let mut timeout_secs = 180; let mut startup_wait_secs = 15; let mut aggregate_events = AggregateEventsMode::OnFailure;