Run cargo fmt on the whole code base (#9394)

* Run cargo fmt on the whole code base

* Second run

* Add CI check

* Fix compilation

* More unnecessary braces

* Handle weights

* Use --all

* Use correct attributes...

* Fix UI tests

* AHHHHHHHHH

* 🤦

* Docs

* Fix compilation

* 🤷

* Please stop

* 🤦 x 2

* More

* make rustfmt.toml consistent with polkadot

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Bastian Köcher
2021-07-21 16:32:32 +02:00
committed by GitHub
parent d451c38c1c
commit 7b56ab15b4
1010 changed files with 53339 additions and 51208 deletions
+27 -25
View File
@@ -18,10 +18,8 @@
use crate::transport::BandwidthSinks;
use prometheus_endpoint::{
self as prometheus,
Counter, CounterVec, Gauge, GaugeVec, HistogramOpts,
PrometheusError, Registry, U64, Opts,
SourcedCounter, SourcedGauge, MetricSource,
self as prometheus, Counter, CounterVec, Gauge, GaugeVec, HistogramOpts, MetricSource, Opts,
PrometheusError, Registry, SourcedCounter, SourcedGauge, U64,
};
use std::{
str,
@@ -267,13 +265,14 @@ impl BandwidthCounters {
/// Registers the `BandwidthCounters` metric whose values are
/// obtained from the given sinks.
fn register(registry: &Registry, sinks: Arc<BandwidthSinks>) -> Result<(), PrometheusError> {
prometheus::register(SourcedCounter::new(
&Opts::new(
"sub_libp2p_network_bytes_total",
"Total bandwidth usage"
).variable_label("direction"),
BandwidthCounters(sinks),
)?, registry)?;
prometheus::register(
SourcedCounter::new(
&Opts::new("sub_libp2p_network_bytes_total", "Total bandwidth usage")
.variable_label("direction"),
BandwidthCounters(sinks),
)?,
registry,
)?;
Ok(())
}
@@ -296,13 +295,16 @@ impl MajorSyncingGauge {
/// Registers the `MajorSyncGauge` metric whose value is
/// obtained from the given `AtomicBool`.
fn register(registry: &Registry, value: Arc<AtomicBool>) -> Result<(), PrometheusError> {
prometheus::register(SourcedGauge::new(
&Opts::new(
"sub_libp2p_is_major_syncing",
"Whether the node is performing a major sync or not.",
),
MajorSyncingGauge(value),
)?, registry)?;
prometheus::register(
SourcedGauge::new(
&Opts::new(
"sub_libp2p_is_major_syncing",
"Whether the node is performing a major sync or not.",
),
MajorSyncingGauge(value),
)?,
registry,
)?;
Ok(())
}
@@ -324,13 +326,13 @@ impl NumConnectedGauge {
/// Registers the `MajorSyncingGauge` metric whose value is
/// obtained from the given `AtomicUsize`.
fn register(registry: &Registry, value: Arc<AtomicUsize>) -> Result<(), PrometheusError> {
prometheus::register(SourcedGauge::new(
&Opts::new(
"sub_libp2p_peers_count",
"Number of connected peers",
),
NumConnectedGauge(value),
)?, registry)?;
prometheus::register(
SourcedGauge::new(
&Opts::new("sub_libp2p_peers_count", "Number of connected peers"),
NumConnectedGauge(value),
)?,
registry,
)?;
Ok(())
}
@@ -30,17 +30,18 @@
//! [`OutChannels::push`] to put the sender within a [`OutChannels`].
//! - Send events by calling [`OutChannels::send`]. Events are cloned for each sender in the
//! collection.
//!
use crate::Event;
use futures::{prelude::*, channel::mpsc, ready, stream::FusedStream};
use futures::{channel::mpsc, prelude::*, ready, stream::FusedStream};
use parking_lot::Mutex;
use prometheus_endpoint::{register, CounterVec, GaugeVec, Opts, PrometheusError, Registry, U64};
use std::{
convert::TryFrom as _,
fmt, pin::Pin, sync::Arc,
task::{Context, Poll}
fmt,
pin::Pin,
sync::Arc,
task::{Context, Poll},
};
/// Creates a new channel that can be associated to a [`OutChannels`].
@@ -100,8 +101,10 @@ impl Stream for Receiver {
let metrics = self.metrics.lock().clone();
match metrics.as_ref().map(|m| m.as_ref()) {
Some(Some(metrics)) => metrics.event_out(&ev, self.name),
Some(None) => (), // no registry
None => log::warn!("Inconsistency in out_events: event happened before sender associated"),
Some(None) => (), // no registry
None => log::warn!(
"Inconsistency in out_events: event happened before sender associated"
),
}
Poll::Ready(Some(ev))
} else {
@@ -136,16 +139,10 @@ pub struct OutChannels {
impl OutChannels {
/// Creates a new empty collection of senders.
pub fn new(registry: Option<&Registry>) -> Result<Self, PrometheusError> {
let metrics = if let Some(registry) = registry {
Some(Metrics::register(registry)?)
} else {
None
};
let metrics =
if let Some(registry) = registry { Some(Metrics::register(registry)?) } else { None };
Ok(OutChannels {
event_streams: Vec::new(),
metrics: Arc::new(metrics),
})
Ok(OutChannels { event_streams: Vec::new(), metrics: Arc::new(metrics) })
}
/// Adds a new [`Sender`] to the collection.
@@ -164,9 +161,8 @@ impl OutChannels {
/// Sends an event.
pub fn send(&mut self, event: Event) {
self.event_streams.retain(|sender| {
sender.inner.unbounded_send(event.clone()).is_ok()
});
self.event_streams
.retain(|sender| sender.inner.unbounded_send(event.clone()).is_ok());
if let Some(metrics) = &*self.metrics {
for ev in &self.event_streams {
@@ -223,20 +219,18 @@ impl Metrics {
fn event_in(&self, event: &Event, num: u64, name: &str) {
match event {
Event::Dht(_) => {
self.events_total
.with_label_values(&["dht", "sent", name])
.inc_by(num);
}
self.events_total.with_label_values(&["dht", "sent", name]).inc_by(num);
},
Event::SyncConnected { .. } => {
self.events_total
.with_label_values(&["sync-connected", "sent", name])
.inc_by(num);
}
},
Event::SyncDisconnected { .. } => {
self.events_total
.with_label_values(&["sync-disconnected", "sent", name])
.inc_by(num);
}
},
Event::NotificationStreamOpened { protocol, .. } => {
self.events_total
.with_label_values(&[&format!("notif-open-{:?}", protocol), "sent", name])
@@ -247,36 +241,31 @@ impl Metrics {
.with_label_values(&[&format!("notif-closed-{:?}", protocol), "sent", name])
.inc_by(num);
},
Event::NotificationsReceived { messages, .. } => {
Event::NotificationsReceived { messages, .. } =>
for (protocol, message) in messages {
self.events_total
.with_label_values(&[&format!("notif-{:?}", protocol), "sent", name])
.inc_by(num);
self.notifications_sizes
.with_label_values(&[protocol, "sent", name])
.inc_by(num.saturating_mul(u64::try_from(message.len()).unwrap_or(u64::MAX)));
}
},
self.notifications_sizes.with_label_values(&[protocol, "sent", name]).inc_by(
num.saturating_mul(u64::try_from(message.len()).unwrap_or(u64::MAX)),
);
},
}
}
fn event_out(&self, event: &Event, name: &str) {
match event {
Event::Dht(_) => {
self.events_total
.with_label_values(&["dht", "received", name])
.inc();
}
self.events_total.with_label_values(&["dht", "received", name]).inc();
},
Event::SyncConnected { .. } => {
self.events_total
.with_label_values(&["sync-connected", "received", name])
.inc();
}
self.events_total.with_label_values(&["sync-connected", "received", name]).inc();
},
Event::SyncDisconnected { .. } => {
self.events_total
.with_label_values(&["sync-disconnected", "received", name])
.inc();
}
},
Event::NotificationStreamOpened { protocol, .. } => {
self.events_total
.with_label_values(&[&format!("notif-open-{:?}", protocol), "received", name])
@@ -287,7 +276,7 @@ impl Metrics {
.with_label_values(&[&format!("notif-closed-{:?}", protocol), "received", name])
.inc();
},
Event::NotificationsReceived { messages, .. } => {
Event::NotificationsReceived { messages, .. } =>
for (protocol, message) in messages {
self.events_total
.with_label_values(&[&format!("notif-{:?}", protocol), "received", name])
@@ -295,8 +284,7 @@ impl Metrics {
self.notifications_sizes
.with_label_values(&[&protocol, "received", name])
.inc_by(u64::try_from(message.len()).unwrap_or(u64::MAX));
}
},
},
}
}
}
+151 -154
View File
@@ -16,13 +16,14 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::{config, Event, NetworkService, NetworkWorker};
use crate::block_request_handler::BlockRequestHandler;
use crate::state_request_handler::StateRequestHandler;
use crate::light_client_requests::handler::LightClientRequestHandler;
use crate::{
block_request_handler::BlockRequestHandler, config,
light_client_requests::handler::LightClientRequestHandler,
state_request_handler::StateRequestHandler, Event, NetworkService, NetworkWorker,
};
use libp2p::PeerId;
use futures::prelude::*;
use libp2p::PeerId;
use sp_runtime::traits::{Block as BlockT, Header as _};
use std::{borrow::Cow, sync::Arc, time::Duration};
use substrate_test_runtime_client::{TestClientBuilder, TestClientBuilderExt as _};
@@ -37,14 +38,10 @@ type TestNetworkService = NetworkService<
///
/// > **Note**: We return the events stream in order to not possibly lose events between the
/// > construction of the service and the moment the events stream is grabbed.
fn build_test_full_node(config: config::NetworkConfiguration)
-> (Arc<TestNetworkService>, impl Stream<Item = Event>)
{
let client = Arc::new(
TestClientBuilder::with_default_backend()
.build_with_longest_chain()
.0,
);
fn build_test_full_node(
config: config::NetworkConfiguration,
) -> (Arc<TestNetworkService>, impl Stream<Item = Event>) {
let client = Arc::new(TestClientBuilder::with_default_backend().build_with_longest_chain().0);
#[derive(Clone)]
struct PassThroughVerifier(bool);
@@ -69,14 +66,13 @@ fn build_test_full_node(config: config::NetworkConfiguration)
.log(|l| {
l.try_as_raw(sp_runtime::generic::OpaqueDigestItemId::Consensus(b"aura"))
.or_else(|| {
l.try_as_raw(sp_runtime::generic::OpaqueDigestItemId::Consensus(b"babe"))
l.try_as_raw(sp_runtime::generic::OpaqueDigestItemId::Consensus(
b"babe",
))
})
})
.map(|blob| {
vec![(
sp_blockchain::well_known_cache_keys::AUTHORITIES,
blob.to_vec(),
)]
vec![(sp_blockchain::well_known_cache_keys::AUTHORITIES, blob.to_vec())]
});
let mut import = sp_consensus::BlockImportParams::new(origin, header);
@@ -99,30 +95,20 @@ fn build_test_full_node(config: config::NetworkConfiguration)
let protocol_id = config::ProtocolId::from("/test-protocol-name");
let block_request_protocol_config = {
let (handler, protocol_config) = BlockRequestHandler::new(
&protocol_id,
client.clone(),
50,
);
let (handler, protocol_config) = BlockRequestHandler::new(&protocol_id, client.clone(), 50);
async_std::task::spawn(handler.run().boxed());
protocol_config
};
let state_request_protocol_config = {
let (handler, protocol_config) = StateRequestHandler::new(
&protocol_id,
client.clone(),
50,
);
let (handler, protocol_config) = StateRequestHandler::new(&protocol_id, client.clone(), 50);
async_std::task::spawn(handler.run().boxed());
protocol_config
};
let light_client_request_protocol_config = {
let (handler, protocol_config) = LightClientRequestHandler::new(
&protocol_id,
client.clone(),
);
let (handler, protocol_config) =
LightClientRequestHandler::new(&protocol_id, client.clone());
async_std::task::spawn(handler.run().boxed());
protocol_config
};
@@ -130,7 +116,9 @@ fn build_test_full_node(config: config::NetworkConfiguration)
let worker = NetworkWorker::new(config::Params {
role: config::Role::Full,
executor: None,
transactions_handler_executor: Box::new(|task| { async_std::task::spawn(task); }),
transactions_handler_executor: Box::new(|task| {
async_std::task::spawn(task);
}),
network_config: config,
chain: client.clone(),
on_demand: None,
@@ -162,43 +150,42 @@ const PROTOCOL_NAME: Cow<'static, str> = Cow::Borrowed("/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()
-> (Arc<TestNetworkService>, impl Stream<Item = Event>, Arc<TestNetworkService>, impl Stream<Item = Event>)
{
fn build_nodes_one_proto() -> (
Arc<TestNetworkService>,
impl Stream<Item = Event>,
Arc<TestNetworkService>,
impl Stream<Item = Event>,
) {
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
let (node1, events_stream1) = build_test_full_node(config::NetworkConfiguration {
extra_sets: vec![
config::NonDefaultSetConfig {
notifications_protocol: PROTOCOL_NAME,
fallback_names: Vec::new(),
max_notification_size: 1024 * 1024,
set_config: Default::default()
}
],
extra_sets: vec![config::NonDefaultSetConfig {
notifications_protocol: PROTOCOL_NAME,
fallback_names: Vec::new(),
max_notification_size: 1024 * 1024,
set_config: Default::default(),
}],
listen_addresses: vec![listen_addr.clone()],
transport: config::TransportConfig::MemoryOnly,
.. config::NetworkConfiguration::new_local()
..config::NetworkConfiguration::new_local()
});
let (node2, events_stream2) = build_test_full_node(config::NetworkConfiguration {
extra_sets: vec![
config::NonDefaultSetConfig {
notifications_protocol: PROTOCOL_NAME,
fallback_names: Vec::new(),
max_notification_size: 1024 * 1024,
set_config: config::SetConfig {
reserved_nodes: vec![config::MultiaddrWithPeerId {
multiaddr: listen_addr,
peer_id: node1.local_peer_id().clone(),
}],
.. Default::default()
}
}
],
extra_sets: vec![config::NonDefaultSetConfig {
notifications_protocol: PROTOCOL_NAME,
fallback_names: Vec::new(),
max_notification_size: 1024 * 1024,
set_config: config::SetConfig {
reserved_nodes: vec![config::MultiaddrWithPeerId {
multiaddr: listen_addr,
peer_id: node1.local_peer_id().clone(),
}],
..Default::default()
},
}],
listen_addresses: vec![],
transport: config::TransportConfig::MemoryOnly,
.. config::NetworkConfiguration::new_local()
..config::NetworkConfiguration::new_local()
});
(node1, events_stream1, node2, events_stream2)
@@ -214,10 +201,18 @@ fn notifications_state_consistent() {
// Write some initial notifications that shouldn't get through.
for _ in 0..(rand::random::<u8>() % 5) {
node1.write_notification(node2.local_peer_id().clone(), PROTOCOL_NAME, b"hello world".to_vec());
node1.write_notification(
node2.local_peer_id().clone(),
PROTOCOL_NAME,
b"hello world".to_vec(),
);
}
for _ in 0..(rand::random::<u8>() % 5) {
node2.write_notification(node1.local_peer_id().clone(), PROTOCOL_NAME, b"hello world".to_vec());
node2.write_notification(
node1.local_peer_id().clone(),
PROTOCOL_NAME,
b"hello world".to_vec(),
);
}
async_std::task::block_on(async move {
@@ -234,16 +229,24 @@ fn notifications_state_consistent() {
iterations += 1;
if iterations >= 1_000 {
assert!(something_happened);
break;
break
}
// Start by sending a notification from node1 to node2 and vice-versa. Part of the
// test consists in ensuring that notifications get ignored if the stream isn't open.
if rand::random::<u8>() % 5 >= 3 {
node1.write_notification(node2.local_peer_id().clone(), PROTOCOL_NAME, b"hello world".to_vec());
node1.write_notification(
node2.local_peer_id().clone(),
PROTOCOL_NAME,
b"hello world".to_vec(),
);
}
if rand::random::<u8>() % 5 >= 3 {
node2.write_notification(node1.local_peer_id().clone(), PROTOCOL_NAME, b"hello world".to_vec());
node2.write_notification(
node1.local_peer_id().clone(),
PROTOCOL_NAME,
b"hello world".to_vec(),
);
}
// Also randomly disconnect the two nodes from time to time.
@@ -272,32 +275,40 @@ fn notifications_state_consistent() {
};
match next_event {
future::Either::Left(Event::NotificationStreamOpened { remote, protocol, .. }) => {
future::Either::Left(Event::NotificationStreamOpened {
remote, protocol, ..
}) => {
something_happened = true;
assert!(!node1_to_node2_open);
node1_to_node2_open = true;
assert_eq!(remote, *node2.local_peer_id());
assert_eq!(protocol, PROTOCOL_NAME);
}
future::Either::Right(Event::NotificationStreamOpened { remote, protocol, .. }) => {
},
future::Either::Right(Event::NotificationStreamOpened {
remote, protocol, ..
}) => {
something_happened = true;
assert!(!node2_to_node1_open);
node2_to_node1_open = true;
assert_eq!(remote, *node1.local_peer_id());
assert_eq!(protocol, PROTOCOL_NAME);
}
future::Either::Left(Event::NotificationStreamClosed { remote, protocol, .. }) => {
},
future::Either::Left(Event::NotificationStreamClosed {
remote, protocol, ..
}) => {
assert!(node1_to_node2_open);
node1_to_node2_open = false;
assert_eq!(remote, *node2.local_peer_id());
assert_eq!(protocol, PROTOCOL_NAME);
}
future::Either::Right(Event::NotificationStreamClosed { remote, protocol, .. }) => {
},
future::Either::Right(Event::NotificationStreamClosed {
remote, protocol, ..
}) => {
assert!(node2_to_node1_open);
node2_to_node1_open = false;
assert_eq!(remote, *node1.local_peer_id());
assert_eq!(protocol, PROTOCOL_NAME);
}
},
future::Either::Left(Event::NotificationsReceived { remote, .. }) => {
assert!(node1_to_node2_open);
assert_eq!(remote, *node2.local_peer_id());
@@ -305,10 +316,10 @@ fn notifications_state_consistent() {
node1.write_notification(
node2.local_peer_id().clone(),
PROTOCOL_NAME,
b"hello world".to_vec()
b"hello world".to_vec(),
);
}
}
},
future::Either::Right(Event::NotificationsReceived { remote, .. }) => {
assert!(node2_to_node1_open);
assert_eq!(remote, *node1.local_peer_id());
@@ -316,18 +327,18 @@ fn notifications_state_consistent() {
node2.write_notification(
node1.local_peer_id().clone(),
PROTOCOL_NAME,
b"hello world".to_vec()
b"hello world".to_vec(),
);
}
}
},
// Add new events here.
future::Either::Left(Event::SyncConnected { .. }) => {}
future::Either::Right(Event::SyncConnected { .. }) => {}
future::Either::Left(Event::SyncDisconnected { .. }) => {}
future::Either::Right(Event::SyncDisconnected { .. }) => {}
future::Either::Left(Event::Dht(_)) => {}
future::Either::Right(Event::Dht(_)) => {}
future::Either::Left(Event::SyncConnected { .. }) => {},
future::Either::Right(Event::SyncConnected { .. }) => {},
future::Either::Left(Event::SyncDisconnected { .. }) => {},
future::Either::Right(Event::SyncDisconnected { .. }) => {},
future::Either::Left(Event::Dht(_)) => {},
future::Either::Right(Event::Dht(_)) => {},
};
}
});
@@ -339,19 +350,14 @@ fn lots_of_incoming_peers_works() {
let (main_node, _) = build_test_full_node(config::NetworkConfiguration {
listen_addresses: vec![listen_addr.clone()],
extra_sets: vec![
config::NonDefaultSetConfig {
notifications_protocol: PROTOCOL_NAME,
fallback_names: Vec::new(),
max_notification_size: 1024 * 1024,
set_config: config::SetConfig {
in_peers: u32::MAX,
.. Default::default()
},
}
],
extra_sets: vec![config::NonDefaultSetConfig {
notifications_protocol: PROTOCOL_NAME,
fallback_names: Vec::new(),
max_notification_size: 1024 * 1024,
set_config: config::SetConfig { in_peers: u32::MAX, ..Default::default() },
}],
transport: config::TransportConfig::MemoryOnly,
.. config::NetworkConfiguration::new_local()
..config::NetworkConfiguration::new_local()
});
let main_node_peer_id = main_node.local_peer_id().clone();
@@ -365,22 +371,20 @@ fn lots_of_incoming_peers_works() {
let (_dialing_node, event_stream) = build_test_full_node(config::NetworkConfiguration {
listen_addresses: vec![],
extra_sets: vec![
config::NonDefaultSetConfig {
notifications_protocol: PROTOCOL_NAME,
fallback_names: Vec::new(),
max_notification_size: 1024 * 1024,
set_config: config::SetConfig {
reserved_nodes: vec![config::MultiaddrWithPeerId {
multiaddr: listen_addr.clone(),
peer_id: main_node_peer_id.clone(),
}],
.. Default::default()
},
}
],
extra_sets: vec![config::NonDefaultSetConfig {
notifications_protocol: PROTOCOL_NAME,
fallback_names: Vec::new(),
max_notification_size: 1024 * 1024,
set_config: config::SetConfig {
reserved_nodes: vec![config::MultiaddrWithPeerId {
multiaddr: listen_addr.clone(),
peer_id: main_node_peer_id.clone(),
}],
..Default::default()
},
}],
transport: config::TransportConfig::MemoryOnly,
.. config::NetworkConfiguration::new_local()
..config::NetworkConfiguration::new_local()
});
background_tasks_to_wait.push(async_std::task::spawn(async move {
@@ -416,9 +420,7 @@ fn lots_of_incoming_peers_works() {
}));
}
futures::executor::block_on(async move {
future::join_all(background_tasks_to_wait).await
});
futures::executor::block_on(async move { future::join_all(background_tasks_to_wait).await });
}
#[test]
@@ -437,14 +439,13 @@ fn notifications_back_pressure() {
while received_notifications < TOTAL_NOTIFS {
match events_stream2.next().await.unwrap() {
Event::NotificationStreamClosed { .. } => panic!(),
Event::NotificationsReceived { messages, .. } => {
Event::NotificationsReceived { messages, .. } =>
for message in messages {
assert_eq!(message.0, PROTOCOL_NAME);
assert_eq!(message.1, format!("hello #{}", received_notifications));
received_notifications += 1;
}
}
_ => {}
},
_ => {},
};
if rand::random::<u8>() < 2 {
@@ -458,7 +459,7 @@ fn notifications_back_pressure() {
loop {
match events_stream1.next().await.unwrap() {
Event::NotificationStreamOpened { .. } => break,
_ => {}
_ => {},
};
}
@@ -483,37 +484,33 @@ fn fallback_name_working() {
let listen_addr = config::build_multiaddr![Memory(rand::random::<u64>())];
let (node1, mut events_stream1) = build_test_full_node(config::NetworkConfiguration {
extra_sets: vec![
config::NonDefaultSetConfig {
notifications_protocol: NEW_PROTOCOL_NAME.clone(),
fallback_names: vec![PROTOCOL_NAME],
max_notification_size: 1024 * 1024,
set_config: Default::default()
}
],
extra_sets: vec![config::NonDefaultSetConfig {
notifications_protocol: NEW_PROTOCOL_NAME.clone(),
fallback_names: vec![PROTOCOL_NAME],
max_notification_size: 1024 * 1024,
set_config: Default::default(),
}],
listen_addresses: vec![listen_addr.clone()],
transport: config::TransportConfig::MemoryOnly,
.. config::NetworkConfiguration::new_local()
..config::NetworkConfiguration::new_local()
});
let (_, mut events_stream2) = build_test_full_node(config::NetworkConfiguration {
extra_sets: vec![
config::NonDefaultSetConfig {
notifications_protocol: PROTOCOL_NAME,
fallback_names: Vec::new(),
max_notification_size: 1024 * 1024,
set_config: config::SetConfig {
reserved_nodes: vec![config::MultiaddrWithPeerId {
multiaddr: listen_addr,
peer_id: node1.local_peer_id().clone(),
}],
.. Default::default()
}
}
],
extra_sets: vec![config::NonDefaultSetConfig {
notifications_protocol: PROTOCOL_NAME,
fallback_names: Vec::new(),
max_notification_size: 1024 * 1024,
set_config: config::SetConfig {
reserved_nodes: vec![config::MultiaddrWithPeerId {
multiaddr: listen_addr,
peer_id: node1.local_peer_id().clone(),
}],
..Default::default()
},
}],
listen_addresses: vec![],
transport: config::TransportConfig::MemoryOnly,
.. config::NetworkConfiguration::new_local()
..config::NetworkConfiguration::new_local()
});
let receiver = async_std::task::spawn(async move {
@@ -525,7 +522,7 @@ fn fallback_name_working() {
assert_eq!(negotiated_fallback, None);
break
},
_ => {}
_ => {},
};
}
});
@@ -539,7 +536,7 @@ fn fallback_name_working() {
assert_eq!(negotiated_fallback, Some(PROTOCOL_NAME));
break
},
_ => {}
_ => {},
};
}
@@ -555,7 +552,7 @@ fn ensure_listen_addresses_consistent_with_transport_memory() {
let _ = build_test_full_node(config::NetworkConfiguration {
listen_addresses: vec![listen_addr.clone()],
transport: config::TransportConfig::MemoryOnly,
.. config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
..config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
});
}
@@ -566,7 +563,7 @@ fn ensure_listen_addresses_consistent_with_transport_not_memory() {
let _ = build_test_full_node(config::NetworkConfiguration {
listen_addresses: vec![listen_addr.clone()],
.. config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
..config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
});
}
@@ -583,7 +580,7 @@ fn ensure_boot_node_addresses_consistent_with_transport_memory() {
listen_addresses: vec![listen_addr.clone()],
transport: config::TransportConfig::MemoryOnly,
boot_nodes: vec![boot_node],
.. config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
..config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
});
}
@@ -599,7 +596,7 @@ fn ensure_boot_node_addresses_consistent_with_transport_not_memory() {
let _ = build_test_full_node(config::NetworkConfiguration {
listen_addresses: vec![listen_addr.clone()],
boot_nodes: vec![boot_node],
.. config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
..config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
});
}
@@ -617,9 +614,9 @@ fn ensure_reserved_node_addresses_consistent_with_transport_memory() {
transport: config::TransportConfig::MemoryOnly,
default_peers_set: config::SetConfig {
reserved_nodes: vec![reserved_node],
.. Default::default()
..Default::default()
},
.. config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
..config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
});
}
@@ -636,9 +633,9 @@ fn ensure_reserved_node_addresses_consistent_with_transport_not_memory() {
listen_addresses: vec![listen_addr.clone()],
default_peers_set: config::SetConfig {
reserved_nodes: vec![reserved_node],
.. Default::default()
..Default::default()
},
.. config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
..config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
});
}
@@ -652,7 +649,7 @@ fn ensure_public_addresses_consistent_with_transport_memory() {
listen_addresses: vec![listen_addr.clone()],
transport: config::TransportConfig::MemoryOnly,
public_addresses: vec![public_address],
.. config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
..config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
});
}
@@ -665,6 +662,6 @@ fn ensure_public_addresses_consistent_with_transport_not_memory() {
let _ = build_test_full_node(config::NetworkConfiguration {
listen_addresses: vec![listen_addr.clone()],
public_addresses: vec![public_address],
.. config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
..config::NetworkConfiguration::new("test-node", "test-client", Default::default(), None)
});
}