Skip to main content

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::{
18    DockerNatBackend, DockerNatConfig, DockerPeerInfo, NatTopology, NatType, NetworkEmulation,
19};
20pub use logs::LogEntry;
21pub use network::{
22    ring_nodes_from_diagnostics, write_ring_visualization_from_diagnostics,
23    NetworkDiagnosticsSnapshot, NetworkTopology, PeerContractStatus, PeerDiagnosticsSnapshot,
24    RingPeerSnapshot, RingVizMetrics, TestNetwork,
25};
26pub use peer::TestPeer;
27pub use remote::{PeerLocation, RemoteMachine};
28
29// Re-export ContractKey for use with collect_ring_snapshot
30pub use freenet_stdlib::prelude::ContractKey;
31
32/// Result type used throughout this crate
33pub type Result<T> = std::result::Result<T, Error>;
34
35/// Errors that can occur when managing test networks
36#[derive(Debug, thiserror::Error)]
37pub enum Error {
38    #[error("Failed to start peer: {0}")]
39    PeerStartupFailed(String),
40
41    #[error("Network connectivity check failed: {0}")]
42    ConnectivityFailed(String),
43
44    #[error("Binary not found or invalid: {0}")]
45    InvalidBinary(String),
46
47    #[error("Port allocation failed: {0}")]
48    PortAllocationFailed(String),
49
50    #[error("IO error: {0}")]
51    Io(#[from] std::io::Error),
52
53    #[error("Other error: {0}")]
54    Other(#[from] anyhow::Error),
55}