pub struct Testnet { /* private fields */ }Expand description
A local test network for Pubky Core development. Can create a flexible amount of pkarr relays, http relays and homeservers.
Keeps track of the components and can create new ones. Cleans up all resources when dropped.
Implementations§
Source§impl Testnet
impl Testnet
Sourcepub async fn new_unseeded() -> Result<Self>
pub async fn new_unseeded() -> Result<Self>
Run a new testnet with a (faster, but partially-initialized) local DHT.
Sourcepub async fn new_with_custom_postgres(
postgres_connection_string: ConnectionString,
) -> Result<Self>
pub async fn new_with_custom_postgres( postgres_connection_string: ConnectionString, ) -> Result<Self>
Run a new testnet with a local DHT. Pass an optional postgres connection string to use for the homeserver. If None, the default test connection string is used.
Sourcepub async fn create_homeserver(&mut self) -> Result<&HomeserverApp>
pub async fn create_homeserver(&mut self) -> Result<&HomeserverApp>
Run the full homeserver app with core and admin server.
Uses ConfigToml::default_test_config() which enables the admin server.
Automatically listens on ephemeral ports and uses this Testnet’s bootstrap nodes and relays.
Sourcepub async fn create_random_homeserver(&mut self) -> Result<&HomeserverApp>
pub async fn create_random_homeserver(&mut self) -> Result<&HomeserverApp>
Run the full homeserver app with core and admin server using a freshly generated random keypair.
Uses ConfigToml::default_test_config() which enables the admin server.
Automatically listens on ephemeral ports and uses this Testnet’s bootstrap nodes and relays.
Sourcepub async fn create_homeserver_app_with_mock(
&mut self,
mock_dir: MockDataDir,
) -> Result<&HomeserverApp>
pub async fn create_homeserver_app_with_mock( &mut self, mock_dir: MockDataDir, ) -> Result<&HomeserverApp>
Run the full homeserver app with core and admin server Automatically listens on the configured ports. Automatically uses the configured bootstrap nodes and relays in this Testnet.
Sourcepub async fn create_http_relay(&mut self) -> Result<&HttpRelay>
pub async fn create_http_relay(&mut self) -> Result<&HttpRelay>
Run an HTTP Relay
Sourcepub async fn create_pkarr_relay(&mut self) -> Result<Url>
pub async fn create_pkarr_relay(&mut self) -> Result<Url>
Run a new Pkarr relay.
You can access the list of relays at Self::pkarr_relays.
Sourcepub fn dht_bootstrap_nodes(&self) -> Vec<DomainPort>
pub fn dht_bootstrap_nodes(&self) -> Vec<DomainPort>
Returns a list of DHT bootstrapping nodes.
Sourcepub fn dht_relay_urls(&self) -> Vec<Url>
pub fn dht_relay_urls(&self) -> Vec<Url>
Returns a list of pkarr relays.
Sourcepub fn client_builder(&self) -> PubkyHttpClientBuilder
pub fn client_builder(&self) -> PubkyHttpClientBuilder
Create a pubky::PubkyHttpClientBuilder and configure it to use this local test network.
Sourcepub fn client(&self) -> Result<PubkyHttpClient, BuildError>
pub fn client(&self) -> Result<PubkyHttpClient, BuildError>
Creates a pubky::PubkyHttpClient pre-configured to use this test network.
This is a convenience method that builds a client from Self::client_builder.
Sourcepub fn sdk(&self) -> Result<Pubky, BuildError>
pub fn sdk(&self) -> Result<Pubky, BuildError>
Creates a pubky::Pubky SDK facade pre-configured to use this test network.
This is a convenience method that builds a client from Self::client_builder.
Sourcepub fn pkarr_client_builder(&self) -> ClientBuilder
pub fn pkarr_client_builder(&self) -> ClientBuilder
Create a pkarr::ClientBuilder and configure it to use this local test network.
Auto Trait Implementations§
impl Freeze for Testnet
impl !RefUnwindSafe for Testnet
impl Send for Testnet
impl Sync for Testnet
impl Unpin for Testnet
impl UnsafeUnpin for Testnet
impl !UnwindSafe for Testnet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request