mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 05:37:58 +00:00
Upgrade tokio to 1.22.0 and replace async-std with tokio (#12646)
* Replace deprecated libp2p feature specs with correct ones * Bump tokio to 1.21.2 * Replace async-std libp2p primitives with tokio ones * minor: rustfmt * Fix TestNet to run initialization in the tokio context * Convert telemetry test from async-std to tokio * Convert notifications tests from async-std to tokio * Convert chain sync tests from async-std to tokio * Ditch async-std completely * Make executor mandatory * Bump tokio to 1.22.0 * minor: rustfmt * Explicitly use tokio runtime in tests * Move more tests to explicit tokio runtime * Explicitly set multithreaded runtime in tokio test * minor: rustfmt * minor: fix comment * Replace async-std with tokio in MMR tests
This commit is contained in:
@@ -44,6 +44,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
use substrate_test_runtime_client::{TestClientBuilder, TestClientBuilderExt as _};
|
||||
use tokio::runtime::Handle;
|
||||
|
||||
fn set_default_expecations_no_peers(
|
||||
chain_sync: &mut MockChainSync<substrate_test_runtime_client::runtime::Block>,
|
||||
@@ -59,7 +60,7 @@ fn set_default_expecations_no_peers(
|
||||
});
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn normal_network_poll_no_peers() {
|
||||
// build `ChainSync` and set default expectations for it
|
||||
let mut chain_sync =
|
||||
@@ -71,7 +72,7 @@ async fn normal_network_poll_no_peers() {
|
||||
let chain_sync_service =
|
||||
Box::new(MockChainSyncInterface::<substrate_test_runtime_client::runtime::Block>::new());
|
||||
|
||||
let mut network = TestNetworkBuilder::new()
|
||||
let mut network = TestNetworkBuilder::new(Handle::current())
|
||||
.with_chain_sync((chain_sync, chain_sync_service))
|
||||
.build();
|
||||
|
||||
@@ -83,7 +84,7 @@ async fn normal_network_poll_no_peers() {
|
||||
.await;
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn request_justification() {
|
||||
// build `ChainSyncInterface` provider and set no expecations for it (i.e., it cannot be
|
||||
// called)
|
||||
@@ -104,7 +105,7 @@ async fn request_justification() {
|
||||
.returning(|_, _| ());
|
||||
|
||||
set_default_expecations_no_peers(&mut chain_sync);
|
||||
let mut network = TestNetworkBuilder::new()
|
||||
let mut network = TestNetworkBuilder::new(Handle::current())
|
||||
.with_chain_sync((chain_sync, chain_sync_service))
|
||||
.build();
|
||||
|
||||
@@ -118,7 +119,7 @@ async fn request_justification() {
|
||||
.await;
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn clear_justification_requests() {
|
||||
// build `ChainSyncInterface` provider and set no expecations for it (i.e., it cannot be
|
||||
// called)
|
||||
@@ -132,7 +133,7 @@ async fn clear_justification_requests() {
|
||||
chain_sync.expect_clear_justification_requests().once().returning(|| ());
|
||||
|
||||
set_default_expecations_no_peers(&mut chain_sync);
|
||||
let mut network = TestNetworkBuilder::new()
|
||||
let mut network = TestNetworkBuilder::new(Handle::current())
|
||||
.with_chain_sync((chain_sync, chain_sync_service))
|
||||
.build();
|
||||
|
||||
@@ -146,7 +147,7 @@ async fn clear_justification_requests() {
|
||||
.await;
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn set_sync_fork_request() {
|
||||
// build `ChainSync` and set default expectations for it
|
||||
let mut chain_sync =
|
||||
@@ -171,7 +172,7 @@ async fn set_sync_fork_request() {
|
||||
.once()
|
||||
.returning(|_, _, _| ());
|
||||
|
||||
let mut network = TestNetworkBuilder::new()
|
||||
let mut network = TestNetworkBuilder::new(Handle::current())
|
||||
.with_chain_sync((chain_sync, Box::new(chain_sync_service)))
|
||||
.build();
|
||||
|
||||
@@ -185,7 +186,7 @@ async fn set_sync_fork_request() {
|
||||
.await;
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn on_block_finalized() {
|
||||
let client = Arc::new(TestClientBuilder::with_default_backend().build_with_longest_chain().0);
|
||||
// build `ChainSyncInterface` provider and set no expecations for it (i.e., it cannot be
|
||||
@@ -215,7 +216,7 @@ async fn on_block_finalized() {
|
||||
.returning(|_, _| ());
|
||||
|
||||
set_default_expecations_no_peers(&mut chain_sync);
|
||||
let mut network = TestNetworkBuilder::new()
|
||||
let mut network = TestNetworkBuilder::new(Handle::current())
|
||||
.with_client(client)
|
||||
.with_chain_sync((chain_sync, chain_sync_service))
|
||||
.build();
|
||||
@@ -232,7 +233,7 @@ async fn on_block_finalized() {
|
||||
|
||||
// report from mock import queue that importing a justification was not successful
|
||||
// and verify that connection to the peer is closed
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn invalid_justification_imported() {
|
||||
struct DummyImportQueue(
|
||||
Arc<
|
||||
@@ -279,13 +280,13 @@ async fn invalid_justification_imported() {
|
||||
let justification_info = Arc::new(RwLock::new(None));
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
|
||||
let (service1, mut event_stream1) = TestNetworkBuilder::new()
|
||||
let (service1, mut event_stream1) = TestNetworkBuilder::new(Handle::current())
|
||||
.with_import_queue(Box::new(DummyImportQueue(justification_info.clone())))
|
||||
.with_listen_addresses(vec![listen_addr.clone()])
|
||||
.build()
|
||||
.start_network();
|
||||
|
||||
let (service2, mut event_stream2) = TestNetworkBuilder::new()
|
||||
let (service2, mut event_stream2) = TestNetworkBuilder::new(Handle::current())
|
||||
.with_set_config(SetConfig {
|
||||
reserved_nodes: vec![MultiaddrWithPeerId {
|
||||
multiaddr: listen_addr,
|
||||
@@ -320,15 +321,12 @@ async fn invalid_justification_imported() {
|
||||
while !std::matches!(event_stream1.next().await, Some(Event::SyncDisconnected { .. })) {}
|
||||
};
|
||||
|
||||
if async_std::future::timeout(Duration::from_secs(5), wait_disconnection)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
if tokio::time::timeout(Duration::from_secs(5), wait_disconnection).await.is_err() {
|
||||
panic!("did not receive disconnection event in time");
|
||||
}
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn disconnect_peer_using_chain_sync_handle() {
|
||||
let client = Arc::new(TestClientBuilder::with_default_backend().build_with_longest_chain().0);
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
@@ -353,7 +351,7 @@ async fn disconnect_peer_using_chain_sync_handle() {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let (node1, mut event_stream1) = TestNetworkBuilder::new()
|
||||
let (node1, mut event_stream1) = TestNetworkBuilder::new(Handle::current())
|
||||
.with_listen_addresses(vec![listen_addr.clone()])
|
||||
.with_chain_sync((Box::new(chain_sync), chain_sync_service))
|
||||
.with_chain_sync_network((chain_sync_network_provider, chain_sync_network_handle))
|
||||
@@ -361,7 +359,7 @@ async fn disconnect_peer_using_chain_sync_handle() {
|
||||
.build()
|
||||
.start_network();
|
||||
|
||||
let (node2, mut event_stream2) = TestNetworkBuilder::new()
|
||||
let (node2, mut event_stream2) = TestNetworkBuilder::new(Handle::current())
|
||||
.with_set_config(SetConfig {
|
||||
reserved_nodes: vec![MultiaddrWithPeerId {
|
||||
multiaddr: listen_addr,
|
||||
@@ -394,10 +392,7 @@ async fn disconnect_peer_using_chain_sync_handle() {
|
||||
while !std::matches!(event_stream1.next().await, Some(Event::SyncDisconnected { .. })) {}
|
||||
};
|
||||
|
||||
if async_std::future::timeout(Duration::from_secs(5), wait_disconnection)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
if tokio::time::timeout(Duration::from_secs(5), wait_disconnection).await.is_err() {
|
||||
panic!("did not receive disconnection event in time");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ use substrate_test_runtime_client::{
|
||||
runtime::{Block as TestBlock, Hash as TestHash},
|
||||
TestClient, TestClientBuilder, TestClientBuilderExt as _,
|
||||
};
|
||||
use tokio::runtime::Handle;
|
||||
|
||||
#[cfg(test)]
|
||||
mod chain_sync;
|
||||
@@ -58,11 +59,12 @@ const PROTOCOL_NAME: &str = "/foo";
|
||||
|
||||
struct TestNetwork {
|
||||
network: TestNetworkWorker,
|
||||
rt_handle: Handle,
|
||||
}
|
||||
|
||||
impl TestNetwork {
|
||||
pub fn new(network: TestNetworkWorker) -> Self {
|
||||
Self { network }
|
||||
pub fn new(network: TestNetworkWorker, rt_handle: Handle) -> Self {
|
||||
Self { network, rt_handle }
|
||||
}
|
||||
|
||||
pub fn service(&self) -> &Arc<TestNetworkService> {
|
||||
@@ -80,7 +82,7 @@ impl TestNetwork {
|
||||
let service = worker.service().clone();
|
||||
let event_stream = service.event_stream("test");
|
||||
|
||||
async_std::task::spawn(async move {
|
||||
self.rt_handle.spawn(async move {
|
||||
futures::pin_mut!(worker);
|
||||
let _ = worker.await;
|
||||
});
|
||||
@@ -97,10 +99,11 @@ struct TestNetworkBuilder {
|
||||
chain_sync: Option<(Box<dyn ChainSyncT<TestBlock>>, Box<dyn ChainSyncInterface<TestBlock>>)>,
|
||||
chain_sync_network: Option<(NetworkServiceProvider, NetworkServiceHandle)>,
|
||||
config: Option<config::NetworkConfiguration>,
|
||||
rt_handle: Handle,
|
||||
}
|
||||
|
||||
impl TestNetworkBuilder {
|
||||
pub fn new() -> Self {
|
||||
pub fn new(rt_handle: Handle) -> Self {
|
||||
Self {
|
||||
import_queue: None,
|
||||
client: None,
|
||||
@@ -109,6 +112,7 @@ impl TestNetworkBuilder {
|
||||
chain_sync: None,
|
||||
chain_sync_network: None,
|
||||
config: None,
|
||||
rt_handle,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,21 +226,21 @@ impl TestNetworkBuilder {
|
||||
let block_request_protocol_config = {
|
||||
let (handler, protocol_config) =
|
||||
BlockRequestHandler::new(&protocol_id, None, client.clone(), 50);
|
||||
async_std::task::spawn(handler.run().boxed());
|
||||
self.rt_handle.spawn(handler.run().boxed());
|
||||
protocol_config
|
||||
};
|
||||
|
||||
let state_request_protocol_config = {
|
||||
let (handler, protocol_config) =
|
||||
StateRequestHandler::new(&protocol_id, None, client.clone(), 50);
|
||||
async_std::task::spawn(handler.run().boxed());
|
||||
self.rt_handle.spawn(handler.run().boxed());
|
||||
protocol_config
|
||||
};
|
||||
|
||||
let light_client_request_protocol_config = {
|
||||
let (handler, protocol_config) =
|
||||
LightClientRequestHandler::new(&protocol_id, None, client.clone());
|
||||
async_std::task::spawn(handler.run().boxed());
|
||||
self.rt_handle.spawn(handler.run().boxed());
|
||||
protocol_config
|
||||
};
|
||||
|
||||
@@ -295,6 +299,11 @@ impl TestNetworkBuilder {
|
||||
(Box::new(chain_sync), chain_sync_service)
|
||||
});
|
||||
|
||||
let handle = self.rt_handle.clone();
|
||||
let executor = move |f| {
|
||||
handle.spawn(f);
|
||||
};
|
||||
|
||||
let worker = NetworkWorker::<
|
||||
substrate_test_runtime_client::runtime::Block,
|
||||
substrate_test_runtime_client::runtime::Hash,
|
||||
@@ -302,7 +311,7 @@ impl TestNetworkBuilder {
|
||||
>::new(config::Params {
|
||||
block_announce_config,
|
||||
role: config::Role::Full,
|
||||
executor: None,
|
||||
executor: Box::new(executor),
|
||||
network_config,
|
||||
chain: client.clone(),
|
||||
protocol_id,
|
||||
@@ -321,10 +330,10 @@ impl TestNetworkBuilder {
|
||||
.unwrap();
|
||||
|
||||
let service = worker.service().clone();
|
||||
async_std::task::spawn(async move {
|
||||
self.rt_handle.spawn(async move {
|
||||
let _ = chain_sync_network_provider.run(service).await;
|
||||
});
|
||||
|
||||
TestNetwork::new(worker)
|
||||
TestNetwork::new(worker, self.rt_handle)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ use sc_network_common::{
|
||||
service::{NetworkNotification, NetworkPeers, NetworkStateInfo},
|
||||
};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use tokio::runtime::Handle;
|
||||
|
||||
type TestNetworkService = NetworkService<
|
||||
substrate_test_runtime_client::runtime::Block,
|
||||
@@ -37,7 +38,9 @@ const PROTOCOL_NAME: &str = "/foo";
|
||||
|
||||
/// Builds two nodes and their associated events stream.
|
||||
/// The nodes are connected together and have the `PROTOCOL_NAME` protocol registered.
|
||||
fn build_nodes_one_proto() -> (
|
||||
fn build_nodes_one_proto(
|
||||
rt_handle: &Handle,
|
||||
) -> (
|
||||
Arc<TestNetworkService>,
|
||||
impl Stream<Item = Event>,
|
||||
Arc<TestNetworkService>,
|
||||
@@ -45,12 +48,12 @@ fn build_nodes_one_proto() -> (
|
||||
) {
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
|
||||
let (node1, events_stream1) = TestNetworkBuilder::new()
|
||||
let (node1, events_stream1) = TestNetworkBuilder::new(rt_handle.clone())
|
||||
.with_listen_addresses(vec![listen_addr.clone()])
|
||||
.build()
|
||||
.start_network();
|
||||
|
||||
let (node2, events_stream2) = TestNetworkBuilder::new()
|
||||
let (node2, events_stream2) = TestNetworkBuilder::new(rt_handle.clone())
|
||||
.with_set_config(SetConfig {
|
||||
reserved_nodes: vec![MultiaddrWithPeerId {
|
||||
multiaddr: listen_addr,
|
||||
@@ -69,7 +72,10 @@ fn notifications_state_consistent() {
|
||||
// Runs two nodes and ensures that events are propagated out of the API in a consistent
|
||||
// correct order, which means no notification received on a closed substream.
|
||||
|
||||
let (node1, mut events_stream1, node2, mut events_stream2) = build_nodes_one_proto();
|
||||
let runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
|
||||
let (node1, mut events_stream1, node2, mut events_stream2) =
|
||||
build_nodes_one_proto(runtime.handle());
|
||||
|
||||
// Write some initial notifications that shouldn't get through.
|
||||
for _ in 0..(rand::random::<u8>() % 5) {
|
||||
@@ -87,7 +93,7 @@ fn notifications_state_consistent() {
|
||||
);
|
||||
}
|
||||
|
||||
async_std::task::block_on(async move {
|
||||
runtime.block_on(async move {
|
||||
// True if we have an active substream from node1 to node2.
|
||||
let mut node1_to_node2_open = false;
|
||||
// True if we have an active substream from node2 to node1.
|
||||
@@ -216,11 +222,11 @@ fn notifications_state_consistent() {
|
||||
});
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn lots_of_incoming_peers_works() {
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
|
||||
let (main_node, _) = TestNetworkBuilder::new()
|
||||
let (main_node, _) = TestNetworkBuilder::new(Handle::current())
|
||||
.with_listen_addresses(vec![listen_addr.clone()])
|
||||
.with_set_config(SetConfig { in_peers: u32::MAX, ..Default::default() })
|
||||
.build()
|
||||
@@ -233,7 +239,7 @@ async fn lots_of_incoming_peers_works() {
|
||||
let mut background_tasks_to_wait = Vec::new();
|
||||
|
||||
for _ in 0..32 {
|
||||
let (_dialing_node, event_stream) = TestNetworkBuilder::new()
|
||||
let (_dialing_node, event_stream) = TestNetworkBuilder::new(Handle::current())
|
||||
.with_set_config(SetConfig {
|
||||
reserved_nodes: vec![MultiaddrWithPeerId {
|
||||
multiaddr: listen_addr.clone(),
|
||||
@@ -244,7 +250,7 @@ async fn lots_of_incoming_peers_works() {
|
||||
.build()
|
||||
.start_network();
|
||||
|
||||
background_tasks_to_wait.push(async_std::task::spawn(async move {
|
||||
background_tasks_to_wait.push(tokio::spawn(async move {
|
||||
// Create a dummy timer that will "never" fire, and that will be overwritten when we
|
||||
// actually need the timer. Using an Option would be technically cleaner, but it would
|
||||
// make the code below way more complicated.
|
||||
@@ -287,10 +293,13 @@ fn notifications_back_pressure() {
|
||||
|
||||
const TOTAL_NOTIFS: usize = 10_000;
|
||||
|
||||
let (node1, mut events_stream1, node2, mut events_stream2) = build_nodes_one_proto();
|
||||
let runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
|
||||
let (node1, mut events_stream1, node2, mut events_stream2) =
|
||||
build_nodes_one_proto(runtime.handle());
|
||||
let node2_id = node2.local_peer_id();
|
||||
|
||||
let receiver = async_std::task::spawn(async move {
|
||||
let receiver = runtime.spawn(async move {
|
||||
let mut received_notifications = 0;
|
||||
|
||||
while received_notifications < TOTAL_NOTIFS {
|
||||
@@ -306,12 +315,12 @@ fn notifications_back_pressure() {
|
||||
};
|
||||
|
||||
if rand::random::<u8>() < 2 {
|
||||
async_std::task::sleep(Duration::from_millis(rand::random::<u64>() % 750)).await;
|
||||
tokio::time::sleep(Duration::from_millis(rand::random::<u64>() % 750)).await;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async_std::task::block_on(async move {
|
||||
runtime.block_on(async move {
|
||||
// Wait for the `NotificationStreamOpened`.
|
||||
loop {
|
||||
match events_stream1.next().await.unwrap() {
|
||||
@@ -331,7 +340,7 @@ fn notifications_back_pressure() {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
receiver.await;
|
||||
receiver.await.unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -341,8 +350,10 @@ fn fallback_name_working() {
|
||||
// they can connect.
|
||||
const NEW_PROTOCOL_NAME: &str = "/new-shiny-protocol-that-isnt-PROTOCOL_NAME";
|
||||
|
||||
let runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
let (node1, mut events_stream1) = TestNetworkBuilder::new()
|
||||
let (node1, mut events_stream1) = TestNetworkBuilder::new(runtime.handle().clone())
|
||||
.with_config(config::NetworkConfiguration {
|
||||
extra_sets: vec![NonDefaultSetConfig {
|
||||
notifications_protocol: NEW_PROTOCOL_NAME.into(),
|
||||
@@ -358,7 +369,7 @@ fn fallback_name_working() {
|
||||
.build()
|
||||
.start_network();
|
||||
|
||||
let (_, mut events_stream2) = TestNetworkBuilder::new()
|
||||
let (_, mut events_stream2) = TestNetworkBuilder::new(runtime.handle().clone())
|
||||
.with_set_config(SetConfig {
|
||||
reserved_nodes: vec![MultiaddrWithPeerId {
|
||||
multiaddr: listen_addr,
|
||||
@@ -369,7 +380,7 @@ fn fallback_name_working() {
|
||||
.build()
|
||||
.start_network();
|
||||
|
||||
let receiver = async_std::task::spawn(async move {
|
||||
let receiver = runtime.spawn(async move {
|
||||
// Wait for the `NotificationStreamOpened`.
|
||||
loop {
|
||||
match events_stream2.next().await.unwrap() {
|
||||
@@ -383,7 +394,7 @@ fn fallback_name_working() {
|
||||
}
|
||||
});
|
||||
|
||||
async_std::task::block_on(async move {
|
||||
runtime.block_on(async move {
|
||||
// Wait for the `NotificationStreamOpened`.
|
||||
loop {
|
||||
match events_stream1.next().await.unwrap() {
|
||||
@@ -397,15 +408,16 @@ fn fallback_name_working() {
|
||||
};
|
||||
}
|
||||
|
||||
receiver.await;
|
||||
receiver.await.unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
// Disconnect peer by calling `Protocol::disconnect_peer()` with the supplied block announcement
|
||||
// protocol name and verify that `SyncDisconnected` event is emitted
|
||||
#[async_std::test]
|
||||
#[tokio::test]
|
||||
async fn disconnect_sync_peer_using_block_announcement_protocol_name() {
|
||||
let (node1, mut events_stream1, node2, mut events_stream2) = build_nodes_one_proto();
|
||||
let (node1, mut events_stream1, node2, mut events_stream2) =
|
||||
build_nodes_one_proto(&Handle::current());
|
||||
|
||||
async fn wait_for_events(stream: &mut (impl Stream<Item = Event> + std::marker::Unpin)) {
|
||||
let mut notif_received = false;
|
||||
@@ -437,12 +449,12 @@ async fn disconnect_sync_peer_using_block_announcement_protocol_name() {
|
||||
assert!(std::matches!(events_stream2.next().await, Some(Event::SyncDisconnected { .. })));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[tokio::test]
|
||||
#[should_panic(expected = "don't match the transport")]
|
||||
fn ensure_listen_addresses_consistent_with_transport_memory() {
|
||||
async fn ensure_listen_addresses_consistent_with_transport_memory() {
|
||||
let listen_addr = config::build_multiaddr![Ip4([127, 0, 0, 1]), Tcp(0_u16)];
|
||||
|
||||
let _ = TestNetworkBuilder::new()
|
||||
let _ = TestNetworkBuilder::new(Handle::current())
|
||||
.with_config(config::NetworkConfiguration {
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
transport: TransportConfig::MemoryOnly,
|
||||
@@ -457,12 +469,12 @@ fn ensure_listen_addresses_consistent_with_transport_memory() {
|
||||
.start_network();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[tokio::test]
|
||||
#[should_panic(expected = "don't match the transport")]
|
||||
fn ensure_listen_addresses_consistent_with_transport_not_memory() {
|
||||
async fn ensure_listen_addresses_consistent_with_transport_not_memory() {
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
|
||||
let _ = TestNetworkBuilder::new()
|
||||
let _ = TestNetworkBuilder::new(Handle::current())
|
||||
.with_config(config::NetworkConfiguration {
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
..config::NetworkConfiguration::new(
|
||||
@@ -476,16 +488,16 @@ fn ensure_listen_addresses_consistent_with_transport_not_memory() {
|
||||
.start_network();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[tokio::test]
|
||||
#[should_panic(expected = "don't match the transport")]
|
||||
fn ensure_boot_node_addresses_consistent_with_transport_memory() {
|
||||
async fn ensure_boot_node_addresses_consistent_with_transport_memory() {
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
let boot_node = MultiaddrWithPeerId {
|
||||
multiaddr: config::build_multiaddr![Ip4([127, 0, 0, 1]), Tcp(0_u16)],
|
||||
peer_id: PeerId::random(),
|
||||
};
|
||||
|
||||
let _ = TestNetworkBuilder::new()
|
||||
let _ = TestNetworkBuilder::new(Handle::current())
|
||||
.with_config(config::NetworkConfiguration {
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
transport: TransportConfig::MemoryOnly,
|
||||
@@ -501,16 +513,16 @@ fn ensure_boot_node_addresses_consistent_with_transport_memory() {
|
||||
.start_network();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[tokio::test]
|
||||
#[should_panic(expected = "don't match the transport")]
|
||||
fn ensure_boot_node_addresses_consistent_with_transport_not_memory() {
|
||||
async fn ensure_boot_node_addresses_consistent_with_transport_not_memory() {
|
||||
let listen_addr = config::build_multiaddr![Ip4([127, 0, 0, 1]), Tcp(0_u16)];
|
||||
let boot_node = MultiaddrWithPeerId {
|
||||
multiaddr: config::build_multiaddr![Memory(rand::random::<u64>())],
|
||||
peer_id: PeerId::random(),
|
||||
};
|
||||
|
||||
let _ = TestNetworkBuilder::new()
|
||||
let _ = TestNetworkBuilder::new(Handle::current())
|
||||
.with_config(config::NetworkConfiguration {
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
boot_nodes: vec![boot_node],
|
||||
@@ -525,16 +537,16 @@ fn ensure_boot_node_addresses_consistent_with_transport_not_memory() {
|
||||
.start_network();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[tokio::test]
|
||||
#[should_panic(expected = "don't match the transport")]
|
||||
fn ensure_reserved_node_addresses_consistent_with_transport_memory() {
|
||||
async fn ensure_reserved_node_addresses_consistent_with_transport_memory() {
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
let reserved_node = MultiaddrWithPeerId {
|
||||
multiaddr: config::build_multiaddr![Ip4([127, 0, 0, 1]), Tcp(0_u16)],
|
||||
peer_id: PeerId::random(),
|
||||
};
|
||||
|
||||
let _ = TestNetworkBuilder::new()
|
||||
let _ = TestNetworkBuilder::new(Handle::current())
|
||||
.with_config(config::NetworkConfiguration {
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
transport: TransportConfig::MemoryOnly,
|
||||
@@ -553,16 +565,16 @@ fn ensure_reserved_node_addresses_consistent_with_transport_memory() {
|
||||
.start_network();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[tokio::test]
|
||||
#[should_panic(expected = "don't match the transport")]
|
||||
fn ensure_reserved_node_addresses_consistent_with_transport_not_memory() {
|
||||
async fn ensure_reserved_node_addresses_consistent_with_transport_not_memory() {
|
||||
let listen_addr = config::build_multiaddr![Ip4([127, 0, 0, 1]), Tcp(0_u16)];
|
||||
let reserved_node = MultiaddrWithPeerId {
|
||||
multiaddr: config::build_multiaddr![Memory(rand::random::<u64>())],
|
||||
peer_id: PeerId::random(),
|
||||
};
|
||||
|
||||
let _ = TestNetworkBuilder::new()
|
||||
let _ = TestNetworkBuilder::new(Handle::current())
|
||||
.with_config(config::NetworkConfiguration {
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
default_peers_set: SetConfig {
|
||||
@@ -580,13 +592,13 @@ fn ensure_reserved_node_addresses_consistent_with_transport_not_memory() {
|
||||
.start_network();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[tokio::test]
|
||||
#[should_panic(expected = "don't match the transport")]
|
||||
fn ensure_public_addresses_consistent_with_transport_memory() {
|
||||
async fn ensure_public_addresses_consistent_with_transport_memory() {
|
||||
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
let public_address = config::build_multiaddr![Ip4([127, 0, 0, 1]), Tcp(0_u16)];
|
||||
|
||||
let _ = TestNetworkBuilder::new()
|
||||
let _ = TestNetworkBuilder::new(Handle::current())
|
||||
.with_config(config::NetworkConfiguration {
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
transport: TransportConfig::MemoryOnly,
|
||||
@@ -602,13 +614,13 @@ fn ensure_public_addresses_consistent_with_transport_memory() {
|
||||
.start_network();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[tokio::test]
|
||||
#[should_panic(expected = "don't match the transport")]
|
||||
fn ensure_public_addresses_consistent_with_transport_not_memory() {
|
||||
async fn ensure_public_addresses_consistent_with_transport_not_memory() {
|
||||
let listen_addr = config::build_multiaddr![Ip4([127, 0, 0, 1]), Tcp(0_u16)];
|
||||
let public_address = config::build_multiaddr![Memory(rand::random::<u64>())];
|
||||
|
||||
let _ = TestNetworkBuilder::new()
|
||||
let _ = TestNetworkBuilder::new(Handle::current())
|
||||
.with_config(config::NetworkConfiguration {
|
||||
listen_addresses: vec![listen_addr.clone()],
|
||||
public_addresses: vec![public_address],
|
||||
|
||||
Reference in New Issue
Block a user