pub struct TestNetwork { /* private fields */ }Expand description
A test network consisting of gateways and peer nodes
Implementations§
Source§impl TestNetwork
impl TestNetwork
Source§impl TestNetwork
impl TestNetwork
Sourcepub fn builder() -> NetworkBuilder
pub fn builder() -> NetworkBuilder
Create a new network builder
Sourcepub fn gateway_ws_urls(&self) -> Vec<String>
pub fn gateway_ws_urls(&self) -> Vec<String>
Get all gateway WebSocket URLs
Sourcepub fn peer_ws_urls(&self) -> Vec<String>
pub fn peer_ws_urls(&self) -> Vec<String>
Get all peer WebSocket URLs
Sourcepub async fn wait_until_ready(&self) -> Result<()>
pub async fn wait_until_ready(&self) -> Result<()>
Wait until the network is ready for use
This checks that peers have formed connections and the network is sufficiently connected for testing.
Sourcepub async fn wait_until_ready_with_timeout(
&self,
timeout: Duration,
) -> Result<()>
pub async fn wait_until_ready_with_timeout( &self, timeout: Duration, ) -> Result<()>
Wait until the network is ready with a custom timeout
Sourcepub async fn check_connectivity_detailed(&self) -> ConnectivityStatus
pub async fn check_connectivity_detailed(&self) -> ConnectivityStatus
Check current network connectivity with detailed status
Sourcepub async fn topology(&self) -> Result<NetworkTopology>
pub async fn topology(&self) -> Result<NetworkTopology>
Get the current network topology
Sourcepub fn export_for_viz(&self) -> String
pub fn export_for_viz(&self) -> String
Export network information in JSON format for visualization tools
Sourcepub async fn collect_diagnostics(&self) -> Result<NetworkDiagnosticsSnapshot>
pub async fn collect_diagnostics(&self) -> Result<NetworkDiagnosticsSnapshot>
Collect diagnostics from every peer, returning a snapshot that can be serialized to JSON for offline analysis.
Sourcepub async fn ring_snapshot(&self) -> Result<Vec<RingPeerSnapshot>>
pub async fn ring_snapshot(&self) -> Result<Vec<RingPeerSnapshot>>
Collect per-peer ring data (locations + adjacency) for visualization/debugging.
Sourcepub async fn collect_ring_snapshot(
&self,
instance_id: Option<&ContractInstanceId>,
) -> Result<Vec<RingPeerSnapshot>>
pub async fn collect_ring_snapshot( &self, instance_id: Option<&ContractInstanceId>, ) -> Result<Vec<RingPeerSnapshot>>
Collect per-peer ring data with optional contract-specific subscription info.
When instance_id is provided, each RingPeerSnapshot will include
PeerContractStatus with subscriber information for that contract.
Sourcepub async fn write_ring_visualization<P: AsRef<Path>>(
&self,
output_path: P,
) -> Result<()>
pub async fn write_ring_visualization<P: AsRef<Path>>( &self, output_path: P, ) -> Result<()>
Generate an interactive HTML ring visualization for the current network.
Sourcepub async fn write_ring_visualization_for_contract<P: AsRef<Path>>(
&self,
output_path: P,
contract_key: &ContractKey,
contract_id: &str,
) -> Result<()>
pub async fn write_ring_visualization_for_contract<P: AsRef<Path>>( &self, output_path: P, contract_key: &ContractKey, contract_id: &str, ) -> Result<()>
Generate an interactive HTML ring visualization for a specific contract.
Note: This function now takes a ContractKey directly instead of a string, since freenet-stdlib 0.1.27 no longer supports ContractKey::from_id. The contract_id string is used for display purposes.
Sourcepub fn dump_logs(&self, filter: Option<&str>)
pub fn dump_logs(&self, filter: Option<&str>)
Dump logs from all peers, optionally filtered by a pattern
If filter is Some, only logs containing the pattern (case-insensitive) are printed.
Logs are printed in chronological order with peer ID prefix.
This is useful for debugging test failures - call it before assertions or in error handlers.
Sourcepub fn dump_connection_logs(&self)
pub fn dump_connection_logs(&self)
Dump logs related to connection establishment and NAT traversal
Filters for: hole punch, NAT, connect, acceptor, joiner, handshake
Sourcepub async fn dump_iptables(&self)
pub async fn dump_iptables(&self)
Dump iptables counters from all NAT routers (Docker NAT only)
Prints NAT table rules and FORWARD chain counters for debugging.
Sourcepub async fn dump_conntrack(&self)
pub async fn dump_conntrack(&self)
Dump conntrack table from all NAT routers (Docker NAT only)
Shows active UDP connection tracking entries for debugging NAT issues.
Sourcepub async fn dump_peer_routes(&self)
pub async fn dump_peer_routes(&self)
Dump routing tables from all peer containers (Docker NAT only)
Shows ip route output for debugging routing issues.