Skip to content

Commit c8ee194

Browse files
iduartgomezclaude
andcommitted
docs(macros): document peer_connectivity_ratio attribute
Add documentation for the new peer_connectivity_ratio attribute in the freenet_test macro README, explaining how it works and when to use it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fb17cc6 commit c8ee194

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

crates/freenet-macros/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,32 @@ Logging level for the test.
205205

206206
**Values:** `"trace"`, `"debug"`, `"info"`, `"warn"`, `"error"`
207207

208+
#### `peer_connectivity_ratio`
209+
Controls the connectivity ratio between peer nodes (0.0-1.0) for testing partially connected networks.
210+
211+
```rust
212+
#[freenet_test(
213+
nodes = ["gw-0", "gw-1", "node-0", "node-1", "node-2", "node-3"],
214+
gateways = ["gw-0", "gw-1"],
215+
auto_connect_peers = true, // Peers connect to all gateways
216+
peer_connectivity_ratio = 0.5 // 50% connectivity between peers
217+
)]
218+
```
219+
220+
**How it works:**
221+
- A ratio of `1.0` means full connectivity between all peers
222+
- A ratio of `0.5` means approximately 50% of peer-to-peer connections are blocked
223+
- A ratio of `0.0` means no direct peer-to-peer connections (only via gateways)
224+
- The blocking pattern is deterministic based on node indices
225+
- Gateway connectivity is not affected - this only controls peer-to-peer connections
226+
227+
**Use cases:**
228+
- Testing subscription propagation in partially connected networks
229+
- Simulating network partitions or unreliable peer connections
230+
- Verifying that updates propagate through gateways when direct peer routes are unavailable
231+
232+
**Note:** When this is set, `auto_connect_peers` should typically be `true` to ensure peers can reach gateways.
233+
208234
## TestContext API
209235

210236
The macro provides a `TestContext` parameter to your test function with these methods:

0 commit comments

Comments
 (0)