pub struct Testnet {
pub bootstrap: Vec<String>,
pub nodes: Vec<Dht>,
}Expand description
Create a testnet of Dht nodes to run tests against instead of the real mainline network.
§Bind Address
The convenience methods (Self::new, Self::new_unseeded, etc.) bind to 0.0.0.0
for backwards compatibility. Use Self::builder to bind to a different address.
Fields§
§bootstrap: Vec<String>bootstrapping nodes for this testnet.
nodes: Vec<Dht>all nodes in this testnet
Implementations§
Source§impl Testnet
impl Testnet
Sourcepub fn builder(count: usize) -> TestnetBuilder
pub fn builder(count: usize) -> TestnetBuilder
Sourcepub fn new(count: usize) -> Result<Testnet, Error>
pub fn new(count: usize) -> Result<Testnet, Error>
Create a new testnet with a certain size.
Note: this network will be shutdown as soon as this struct
gets dropped, if you want the network to be 'static, then
you should call Self::leak.
This will block until all nodes are seeded with local peers. If you are using an async runtime, consider using Self::new_async.
§Bind Address
Nodes are bound to 0.0.0.0 (all interfaces). Use Self::builder to bind to
a different address.
Sourcepub fn new_unseeded(count: usize) -> Result<Testnet, Error>
pub fn new_unseeded(count: usize) -> Result<Testnet, Error>
Create a new testnet without pre-seeding routing tables.
This is faster at startup, but nodes will not start with fully populated routing tables. Use this when your tests do not require immediate full connectivity.
§Bind Address
Nodes are bound to 0.0.0.0 (all interfaces). Use Self::builder with .seeded(false)
to bind to a different address.
Sourcepub async fn new_async(count: usize) -> Result<Testnet, Error>
pub async fn new_async(count: usize) -> Result<Testnet, Error>
Similar to Self::new, but available for async contexts.
§Bind Address
Nodes are bound to 0.0.0.0 (all interfaces). Use Self::builder to bind to
a different address.
Sourcepub async fn new_unseeded_async(count: usize) -> Result<Testnet, Error>
pub async fn new_unseeded_async(count: usize) -> Result<Testnet, Error>
Similar to Self::new_unseeded, but available for async contexts.
§Bind Address
Nodes are bound to 0.0.0.0 (all interfaces). Use Self::builder with .seeded(false)
to bind to a different address.