freenet_test_network/
lib.rs

1//! Reliable test network infrastructure for Freenet
2//!
3//! This crate provides tools for spinning up and managing local Freenet test networks
4//! for integration testing.
5
6mod binary;
7mod builder;
8pub mod docker;
9mod logs;
10mod network;
11mod peer;
12mod process;
13mod remote;
14
15pub use binary::{BuildProfile, FreenetBinary};
16pub use builder::{Backend, NetworkBuilder};
17pub use docker::{DockerNatBackend, DockerNatConfig, DockerPeerInfo, NatTopology, NatType};
18pub use logs::LogEntry;
19pub use network::{
20    ring_nodes_from_diagnostics, write_ring_visualization_from_diagnostics,
21    NetworkDiagnosticsSnapshot, NetworkTopology, PeerContractStatus, PeerDiagnosticsSnapshot,
22    RingPeerSnapshot, RingVizMetrics, TestNetwork,
23};
24pub use peer::TestPeer;
25pub use remote::{PeerLocation, RemoteMachine};
26
27// Re-export ContractKey for use with collect_ring_snapshot
28pub use freenet_stdlib::prelude::ContractKey;
29
30/// Result type used throughout this crate
31pub type Result<T> = std::result::Result<T, Error>;
32
33/// Errors that can occur when managing test networks
34#[derive(Debug, thiserror::Error)]
35pub enum Error {
36    #[error("Failed to start peer: {0}")]
37    PeerStartupFailed(String),
38
39    #[error("Network connectivity check failed: {0}")]
40    ConnectivityFailed(String),
41
42    #[error("Binary not found or invalid: {0}")]
43    InvalidBinary(String),
44
45    #[error("Port allocation failed: {0}")]
46    PortAllocationFailed(String),
47
48    #[error("IO error: {0}")]
49    Io(#[from] std::io::Error),
50
51    #[error("Other error: {0}")]
52    Other(#[from] anyhow::Error),
53}