Skip to content

Commit 42bfc46

Browse files
sanityclaude
andauthored
fix(test): change auto_connect_peers default to true (#2221)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7de78c3 commit 42bfc46

File tree

6 files changed

+29
-44
lines changed

6 files changed

+29
-44
lines changed

crates/core/tests/connectivity.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ fn fixed_three_node_locations() -> Vec<f64> {
2323
/// connecting to the gateway.
2424
#[freenet_test(
2525
nodes = ["gateway", "peer"],
26-
auto_connect_peers = true,
2726
timeout_secs = 180,
2827
startup_wait_secs = 15,
2928
aggregate_events = "always",
@@ -256,7 +255,6 @@ async fn test_basic_gateway_connectivity(ctx: &mut TestContext) -> TestResult {
256255
///
257256
#[freenet_test(
258257
nodes = ["gateway", "peer1", "peer2"],
259-
auto_connect_peers = true,
260258
timeout_secs = 180,
261259
startup_wait_secs = 30,
262260
node_locations_fn = fixed_three_node_locations,
@@ -541,7 +539,6 @@ async fn perform_put_with_retries(
541539
/// when promoting transients.
542540
#[freenet_test(
543541
nodes = ["gateway", "peer"],
544-
auto_connect_peers = true,
545542
timeout_secs = 60,
546543
startup_wait_secs = 15,
547544
aggregate_events = "always",

crates/core/tests/operations.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ async fn send_put_with_retry(
216216
/// Test PUT operation across two peers (gateway and peer)
217217
#[freenet_test(
218218
nodes = ["gateway", "peer-a"],
219-
auto_connect_peers = true,
220219
timeout_secs = 180,
221220
startup_wait_secs = 15,
222221
tokio_flavor = "multi_thread",
@@ -324,7 +323,6 @@ async fn test_put_contract(ctx: &mut TestContext) -> TestResult {
324323

325324
#[freenet_test(
326325
nodes = ["gateway", "peer-a"],
327-
auto_connect_peers = true,
328326
timeout_secs = 180,
329327
startup_wait_secs = 20,
330328
tokio_flavor = "multi_thread",
@@ -495,7 +493,6 @@ async fn test_update_contract(ctx: &mut TestContext) -> TestResult {
495493
/// This is a regression test for issue #1995.
496494
#[freenet_test(
497495
nodes = ["gateway", "peer-a"],
498-
auto_connect_peers = true,
499496
timeout_secs = 180,
500497
startup_wait_secs = 15,
501498
tokio_flavor = "multi_thread",
@@ -646,7 +643,6 @@ async fn test_put_merge_persists_state(ctx: &mut TestContext) -> TestResult {
646643
#[ignore]
647644
#[freenet_test(
648645
nodes = ["gateway", "node-a", "node-b"],
649-
auto_connect_peers = true,
650646
timeout_secs = 600,
651647
startup_wait_secs = 40,
652648
tokio_flavor = "multi_thread",
@@ -1220,7 +1216,6 @@ async fn test_multiple_clients_subscription(ctx: &mut TestContext) -> TestResult
12201216

12211217
#[freenet_test(
12221218
nodes = ["gateway", "node-a"],
1223-
auto_connect_peers = true,
12241219
timeout_secs = 120,
12251220
startup_wait_secs = 20,
12261221
tokio_flavor = "multi_thread",
@@ -1448,7 +1443,6 @@ async fn test_get_with_subscribe_flag(ctx: &mut TestContext) -> TestResult {
14481443
// FIXME Update notification is not received
14491444
#[freenet_test(
14501445
nodes = ["gateway", "node-a"],
1451-
auto_connect_peers = true,
14521446
timeout_secs = 180,
14531447
startup_wait_secs = 20,
14541448
tokio_flavor = "multi_thread",
@@ -1738,7 +1732,6 @@ async fn test_put_with_subscribe_flag(ctx: &mut TestContext) -> TestResult {
17381732

17391733
#[freenet_test(
17401734
nodes = ["gateway", "client-node"],
1741-
auto_connect_peers = true,
17421735
timeout_secs = 180,
17431736
startup_wait_secs = 20,
17441737
tokio_flavor = "multi_thread",
@@ -1936,7 +1929,6 @@ fn expected_three_hop_locations() -> [f64; 3] {
19361929
"peer-a": { location: three_hop_peer_a_location() },
19371930
"peer-c": { location: three_hop_peer_c_location() },
19381931
},
1939-
auto_connect_peers = true,
19401932
timeout_secs = 240,
19411933
startup_wait_secs = 15,
19421934
aggregate_events = "on_failure",
@@ -2531,7 +2523,6 @@ async fn wait_for_subscribe_response(
25312523

25322524
#[freenet_test(
25332525
nodes = ["gateway", "peer-node"],
2534-
auto_connect_peers = true,
25352526
timeout_secs = 180,
25362527
startup_wait_secs = 10,
25372528
tokio_flavor = "multi_thread",
@@ -2605,7 +2596,6 @@ async fn test_subscription_introspection(ctx: &mut TestContext) -> TestResult {
26052596

26062597
#[freenet_test(
26072598
nodes = ["gateway", "peer-a"],
2608-
auto_connect_peers = true,
26092599
timeout_secs = 180,
26102600
startup_wait_secs = 20,
26112601
tokio_flavor = "multi_thread",

crates/core/tests/test_macro_example.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,14 @@ async fn test_multiple_gateways(ctx: &mut TestContext) -> TestResult {
209209
Ok(())
210210
}
211211

212-
/// Test with auto_connect_peers enabled
212+
/// Test with auto_connect_peers enabled (now the default)
213213
#[freenet_test(
214214
nodes = ["gateway", "peer-1", "peer-2"],
215-
auto_connect_peers = true,
216215
timeout_secs = 120,
217216
startup_wait_secs = 15
218217
)]
219218
async fn test_auto_connect_peers(ctx: &mut TestContext) -> TestResult {
220-
// With auto_connect_peers=true, all peer nodes are configured to
219+
// With auto_connect_peers=true (now default), all peer nodes are configured to
221220
// connect to all gateway nodes automatically
222221

223222
let gateway = ctx.gateway()?;
@@ -238,16 +237,15 @@ async fn test_auto_connect_peers(ctx: &mut TestContext) -> TestResult {
238237
Ok(())
239238
}
240239

241-
/// Test with multiple gateways and auto_connect_peers
240+
/// Test with multiple gateways and auto_connect_peers (now the default)
242241
#[freenet_test(
243242
nodes = ["gw-1", "gw-2", "peer-1", "peer-2"],
244243
gateways = ["gw-1", "gw-2"],
245-
auto_connect_peers = true,
246244
timeout_secs = 120,
247245
startup_wait_secs = 15
248246
)]
249247
async fn test_multi_gateway_auto_connect(ctx: &mut TestContext) -> TestResult {
250-
// With auto_connect_peers=true and multiple gateways,
248+
// With auto_connect_peers=true (now default) and multiple gateways,
251249
// all peer nodes are configured to connect to ALL gateway nodes
252250

253251
let gateways = ctx.gateways();

crates/freenet-macros/README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,18 @@ async fn test_basic_gateway(ctx: &mut TestContext) -> TestResult {
2929
}
3030
```
3131

32-
### Multi-Node Test with Auto-Connect
32+
### Multi-Node Test
3333

3434
```rust
3535
#[freenet_test(
3636
nodes = ["gateway", "peer-1", "peer-2"],
37-
auto_connect_peers = true,
3837
aggregate_events = "on_failure"
3938
)]
4039
async fn test_network_operations(ctx: &mut TestContext) -> TestResult {
4140
let gateway = ctx.gateway()?;
4241
let peers = ctx.peers();
4342

44-
// All peers are automatically configured to connect to the gateway
43+
// All peers automatically connect to the gateway (default behavior)
4544
assert_eq!(peers.len(), 2);
4645

4746
// Your test logic here...
@@ -88,8 +87,7 @@ Set explicit ring locations for nodes (order must match the `nodes` list). This
8887
```rust
8988
#[freenet_test(
9089
nodes = ["gateway", "peer-a", "peer-b"],
91-
node_locations = [0.2, 0.6, 0.85], // gateway, peer-a, peer-b
92-
auto_connect_peers = true
90+
node_locations = [0.2, 0.6, 0.85] // gateway, peer-a, peer-b
9391
)]
9492
async fn test_with_locations(ctx: &mut TestContext) -> TestResult {
9593
// Test logic here...
@@ -113,8 +111,7 @@ fn my_locations() -> Vec<f64> {
113111

114112
#[freenet_test(
115113
nodes = ["gateway", "peer-a", "peer-b"],
116-
node_locations_fn = my_locations,
117-
auto_connect_peers = true
114+
node_locations_fn = my_locations
118115
)]
119116
```
120117

@@ -147,18 +144,22 @@ async fn test_with_node_configs(ctx: &mut TestContext) -> TestResult {
147144
#### `auto_connect_peers`
148145
Automatically configure all peer nodes to connect to all gateway nodes.
149146

147+
**Behavior:**
148+
- When `true` (default): Peers are pre-configured with gateway connection info
149+
- When `false`: You must manually configure peer connections
150+
- Works with multiple gateways (peers connect to all gateways)
151+
150152
```rust
153+
// Default behavior - peers auto-connect to gateways
154+
#[freenet_test(nodes = ["gateway", "peer-1", "peer-2"])]
155+
156+
// Disable auto-connect for manual connection setup
151157
#[freenet_test(
152158
nodes = ["gateway", "peer-1", "peer-2"],
153-
auto_connect_peers = true // Peers auto-connect to gateway
159+
auto_connect_peers = false
154160
)]
155161
```
156162

157-
**Behavior:**
158-
- When `true`: Peers are pre-configured with gateway connection info
159-
- When `false` (default): You must manually configure peer connections
160-
- Works with multiple gateways (peers connect to all gateways)
161-
162163
#### `aggregate_events`
163164
Control when event aggregation reports are generated.
164165

@@ -324,7 +325,6 @@ use freenet_stdlib::prelude::*;
324325

325326
#[freenet_test(
326327
nodes = ["gateway", "peer-1", "peer-2"],
327-
auto_connect_peers = true,
328328
timeout_secs = 180,
329329
startup_wait_secs = 15,
330330
aggregate_events = "on_failure",
@@ -474,7 +474,6 @@ EVENT LOG SUMMARY
474474
#[freenet_test(
475475
nodes = ["gw-1", "gw-2", "peer-1", "peer-2", "peer-3", "peer-4"],
476476
gateways = ["gw-1", "gw-2"],
477-
auto_connect_peers = true,
478477
startup_wait_secs = 20 // More time for connections to establish
479478
)]
480479
```
@@ -561,9 +560,10 @@ Each approach has significant trade-offs. Using `Result`-based errors is the idi
561560
**Problem:** Peers don't connect to gateway
562561

563562
**Solutions:**
564-
1. Use `auto_connect_peers = true` to handle connection setup automatically
565-
2. Increase `startup_wait_secs` to allow more time for connections
566-
3. Check gateway network port is set correctly
563+
1. `auto_connect_peers` is `true` by default, so connection setup is automatic
564+
2. If using `auto_connect_peers = false`, ensure manual connection setup is correct
565+
3. Increase `startup_wait_secs` to allow more time for connections
566+
4. Check gateway network port is set correctly
567567

568568
### Multi-Gateway Tests Fail
569569

crates/freenet-macros/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use parser::FreenetTestArgs;
4545
///
4646
/// - `nodes` (required): Array of node labels
4747
/// - `gateways` (optional): Array of nodes that should be gateways. If not specified, the first node is a gateway.
48-
/// - `auto_connect_peers` (optional): If true, peer nodes are configured to connect to all gateway nodes (default: false)
48+
/// - `auto_connect_peers` (optional): If true, peer nodes are configured to connect to all gateway nodes (default: true)
4949
/// - `timeout_secs` (optional): Test timeout in seconds (default: 180)
5050
/// - `startup_wait_secs` (optional): Node startup wait in seconds (default: 15)
5151
/// - `aggregate_events` (optional): When to aggregate events:
@@ -86,18 +86,18 @@ use parser::FreenetTestArgs;
8686
/// }
8787
/// ```
8888
///
89-
/// ## Auto-Connect Peers to Gateways
89+
/// ## Disabling Auto-Connect (peers connect to gateways by default)
9090
/// ```ignore
9191
/// #[freenet_test(
9292
/// nodes = ["gateway", "peer-1", "peer-2"],
93-
/// auto_connect_peers = true, // Peers will connect to gateway
93+
/// auto_connect_peers = false, // Disable automatic peer-to-gateway connections
9494
/// timeout_secs = 120
9595
/// )]
96-
/// async fn test_with_connections(ctx: &mut TestContext) -> TestResult {
97-
/// // Peers are configured to discover and connect to the gateway
96+
/// async fn test_manual_connections(ctx: &mut TestContext) -> TestResult {
97+
/// // Peers must manually discover and connect to the gateway
9898
/// let gateway = ctx.gateway()?;
9999
/// let peers = ctx.peers();
100-
/// // Test peer-gateway interactions...
100+
/// // Set up manual connections...
101101
/// Ok(())
102102
/// }
103103
/// ```

crates/freenet-macros/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl syn::parse::Parse for FreenetTestArgs {
5050
let mut gateways = None;
5151
let mut node_locations = None;
5252
let mut node_locations_fn = None;
53-
let mut auto_connect_peers = false;
53+
let mut auto_connect_peers = true;
5454
let mut timeout_secs = 180;
5555
let mut startup_wait_secs = 15;
5656
let mut aggregate_events = AggregateEventsMode::OnFailure;

0 commit comments

Comments
 (0)