feat: adding a new method to network config builder (#11569)

This commit is contained in:
Luca Provini
2024-10-08 15:27:42 +02:00
committed by GitHub
parent 67db43d0ac
commit 946f1a4c18
2 changed files with 13 additions and 0 deletions

View File

@@ -271,6 +271,7 @@ pub async fn test_exex_context_with_chain_spec(
let network_manager = NetworkManager::new(
NetworkConfigBuilder::new(SecretKey::new(&mut rand::thread_rng()))
.with_unused_discovery_port()
.build(provider_factory.clone()),
)
.await?;

View File

@@ -347,6 +347,18 @@ impl NetworkConfigBuilder {
self
}
/// Sets the discovery port to an unused port.
/// This is useful for testing.
pub fn with_unused_discovery_port(self) -> Self {
self.discovery_port(0)
}
/// Sets the listener port to an unused port.
/// This is useful for testing.
pub fn with_unused_listener_port(self) -> Self {
self.listener_port(0)
}
/// Sets the external ip resolver to use for discovery v4.
///
/// If no [`Discv4ConfigBuilder`] is set via [`Self::discovery`], this will create a new one.