Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions crates/core/tests/connectivity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ fn fixed_three_node_locations() -> Vec<f64> {
/// connecting to the gateway.
#[freenet_test(
nodes = ["gateway", "peer"],
auto_connect_peers = true,
timeout_secs = 180,
startup_wait_secs = 15,
aggregate_events = "always",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 0 additions & 10 deletions crates/core/tests/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 4 additions & 6 deletions crates/core/tests/test_macro_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand All @@ -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();
Expand Down
36 changes: 18 additions & 18 deletions crates/freenet-macros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -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...
Expand All @@ -113,8 +111,7 @@ fn my_locations() -> Vec<f64> {

#[freenet_test(
nodes = ["gateway", "peer-a", "peer-b"],
node_locations_fn = my_locations,
auto_connect_peers = true
node_locations_fn = my_locations
)]
```

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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
)]
```
Expand Down Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions crates/freenet-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(())
/// }
/// ```
Expand Down
2 changes: 1 addition & 1 deletion crates/freenet-macros/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading