|
@@ -18,9 +18,10 @@
|
|
|
|
|
|
|
|
// cargo +nightly test --release --features=net --lib p2p -- --include-ignored
|
|
// cargo +nightly test --release --features=net --lib p2p -- --include-ignored
|
|
|
|
|
|
|
|
|
|
+use simplelog::ThreadLogMode;
|
|
|
use std::sync::Arc;
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
-use log::info;
|
|
|
|
|
|
|
+use log::{debug, info};
|
|
|
use rand::Rng;
|
|
use rand::Rng;
|
|
|
use smol::{channel, future, Executor};
|
|
use smol::{channel, future, Executor};
|
|
|
use url::Url;
|
|
use url::Url;
|
|
@@ -31,16 +32,45 @@ use crate::{
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// Number of nodes to spawn and number of peers each node connects to
|
|
// Number of nodes to spawn and number of peers each node connects to
|
|
|
-const N_NODES: usize = 6;
|
|
|
|
|
-const N_CONNS: usize = 1;
|
|
|
|
|
|
|
+const N_NODES: usize = 20;
|
|
|
|
|
+//const N_CONNS: usize = 3;
|
|
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
|
fn p2p_test() {
|
|
fn p2p_test() {
|
|
|
let mut cfg = simplelog::ConfigBuilder::new();
|
|
let mut cfg = simplelog::ConfigBuilder::new();
|
|
|
|
|
|
|
|
|
|
+ //cfg.set_thread_mode(ThreadLogMode::Both);
|
|
|
|
|
+ cfg.add_filter_ignore("sled".to_string());
|
|
|
|
|
+ //cfg.add_filter_ignore("deadlock".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::protocol_ping".to_string());
|
|
|
|
|
+ //cfg.add_filter_ignore("net::channel::subscribe_stop()".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::hosts".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::inbound_session".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("outbound_session".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::outbound_session".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::session::outbound_session".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::session".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::refinery".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::message_subscriber".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::protocol_address".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::protocol_jobs_manager".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::protocol_version".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::protocol_registry".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::protocol_seed".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::channel".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::p2p::seed".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::p2p::start".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("store".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::store".to_string());
|
|
|
|
|
+ //cfg.add_filter_ignore("net::channel::send()".to_string());
|
|
|
|
|
+ //cfg.add_filter_ignore("net::channel::start()".to_string());
|
|
|
|
|
+ //cfg.add_filter_ignore("net::channel::subscribe_msg()".to_string());
|
|
|
|
|
+ //cfg.add_filter_ignore("net::channel::main_receive_loop()".to_string());
|
|
|
|
|
+ cfg.add_filter_ignore("net::tcp".to_string());
|
|
|
|
|
+
|
|
|
simplelog::TermLogger::init(
|
|
simplelog::TermLogger::init(
|
|
|
- simplelog::LevelFilter::Info,
|
|
|
|
|
- //simplelog::LevelFilter::Debug,
|
|
|
|
|
|
|
+ //simplelog::LevelFilter::Info,
|
|
|
|
|
+ simplelog::LevelFilter::Debug,
|
|
|
//simplelog::LevelFilter::Trace,
|
|
//simplelog::LevelFilter::Trace,
|
|
|
cfg.build(),
|
|
cfg.build(),
|
|
|
simplelog::TerminalMode::Mixed,
|
|
simplelog::TerminalMode::Mixed,
|
|
@@ -73,7 +103,7 @@ async fn hostlist_propagation(ex: Arc<Executor<'static>>) {
|
|
|
localnet: true,
|
|
localnet: true,
|
|
|
inbound_addrs: vec![seed_addr.clone()],
|
|
inbound_addrs: vec![seed_addr.clone()],
|
|
|
external_addrs: vec![seed_addr.clone()],
|
|
external_addrs: vec![seed_addr.clone()],
|
|
|
- outbound_connections: 2,
|
|
|
|
|
|
|
+ outbound_connections: 0,
|
|
|
//outbound_connect_timeout: 10,
|
|
//outbound_connect_timeout: 10,
|
|
|
inbound_connections: usize::MAX,
|
|
inbound_connections: usize::MAX,
|
|
|
seeds: vec![],
|
|
seeds: vec![],
|
|
@@ -102,7 +132,7 @@ async fn hostlist_propagation(ex: Arc<Executor<'static>>) {
|
|
|
localnet: true,
|
|
localnet: true,
|
|
|
inbound_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{}", 13200 + i)).unwrap()],
|
|
inbound_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{}", 13200 + i)).unwrap()],
|
|
|
external_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{}", 13200 + i)).unwrap()],
|
|
external_addrs: vec![Url::parse(&format!("tcp://127.0.0.1:{}", 13200 + i)).unwrap()],
|
|
|
- outbound_connections: 2,
|
|
|
|
|
|
|
+ outbound_connections: 8,
|
|
|
//outbound_connect_timeout: 10,
|
|
//outbound_connect_timeout: 10,
|
|
|
inbound_connections: usize::MAX,
|
|
inbound_connections: usize::MAX,
|
|
|
seeds: vec![seed_addr.clone()],
|
|
seeds: vec![seed_addr.clone()],
|
|
@@ -110,6 +140,7 @@ async fn hostlist_propagation(ex: Arc<Executor<'static>>) {
|
|
|
peers,
|
|
peers,
|
|
|
allowed_transports: vec!["tcp".to_string()],
|
|
allowed_transports: vec!["tcp".to_string()],
|
|
|
node_id: i.to_string(),
|
|
node_id: i.to_string(),
|
|
|
|
|
+ anchor_connection_count: 2,
|
|
|
..Default::default()
|
|
..Default::default()
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -122,37 +153,39 @@ async fn hostlist_propagation(ex: Arc<Executor<'static>>) {
|
|
|
p2p.clone().start().await.unwrap();
|
|
p2p.clone().start().await.unwrap();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- info!("Waiting until all peers connect");
|
|
|
|
|
- sleep(15).await;
|
|
|
|
|
-
|
|
|
|
|
- //info!("Inspecting hostlists...");
|
|
|
|
|
- //for p2p in p2p_instances.iter() {
|
|
|
|
|
- // let hosts = p2p.hosts();
|
|
|
|
|
- // //assert!(!hosts.is_empty_greylist().await);
|
|
|
|
|
- // //assert!(!hosts.is_empty_whitelist().await);
|
|
|
|
|
- // //assert!(!hosts.is_empty_anchorlist().await);
|
|
|
|
|
|
|
+ //info!("Waiting until all peers connect");
|
|
|
|
|
+ sleep(30).await;
|
|
|
|
|
|
|
|
- // let greylist = hosts.greylist.read().await;
|
|
|
|
|
- // let whitelist = hosts.whitelist.read().await;
|
|
|
|
|
- // let anchorlist = hosts.anchorlist.read().await;
|
|
|
|
|
-
|
|
|
|
|
- // info!("Node {}", p2p.settings().node_id);
|
|
|
|
|
- // for (i, (url, last_seen)) in greylist.iter().enumerate() {
|
|
|
|
|
- // info!("Greylist entry {}: {}, {}", i, url, last_seen);
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ info!("Inspecting hostlists...");
|
|
|
|
|
+ for p2p in p2p_instances.iter() {
|
|
|
|
|
+ let hosts = p2p.hosts();
|
|
|
|
|
+ //assert!(!hosts.is_empty_greylist().await);
|
|
|
|
|
+ //assert!(!hosts.is_empty_whitelist().await);
|
|
|
|
|
+ //assert!(!hosts.is_empty_anchorlist().await);
|
|
|
|
|
+
|
|
|
|
|
+ //let greylist = hosts.greylist.read().await;
|
|
|
|
|
+ //let whitelist = hosts.whitelist.read().await;
|
|
|
|
|
+ //let anchorlist = hosts.anchorlist.read().await;
|
|
|
|
|
+
|
|
|
|
|
+ //info!("Node {}", p2p.settings().node_id);
|
|
|
|
|
+ //for (i, (url, last_seen)) in greylist.iter().enumerate() {
|
|
|
|
|
+ // info!("Greylist entry {}: {}, {}", i, url, last_seen);
|
|
|
|
|
+ //}
|
|
|
|
|
|
|
|
- // for (i, (url, last_seen)) in whitelist.iter().enumerate() {
|
|
|
|
|
- // info!("Whitelist entry {}: {}, {}", i, url, last_seen);
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ //for (i, (url, last_seen)) in whitelist.iter().enumerate() {
|
|
|
|
|
+ // info!("Whitelist entry {}: {}, {}", i, url, last_seen);
|
|
|
|
|
+ //}
|
|
|
|
|
|
|
|
- // for (i, (url, last_seen)) in anchorlist.iter().enumerate() {
|
|
|
|
|
- // info!("Anchorlist entry {}: {}, {}", i, url, last_seen);
|
|
|
|
|
- // }
|
|
|
|
|
- //}
|
|
|
|
|
|
|
+ //for (i, (url, last_seen)) in anchorlist.iter().enumerate() {
|
|
|
|
|
+ // info!("Anchorlist entry {}: {}, {}", i, url, last_seen);
|
|
|
|
|
+ //}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// Stop the P2P network
|
|
// Stop the P2P network
|
|
|
for p2p in p2p_instances.iter() {
|
|
for p2p in p2p_instances.iter() {
|
|
|
- info!("Stopping P2P instances...");
|
|
|
|
|
|
|
+ //info!("Stopping P2P instances...");
|
|
|
|
|
+ debug!("Stopping P2P instances...");
|
|
|
p2p.clone().stop().await;
|
|
p2p.clone().stop().await;
|
|
|
|
|
+ debug!("node {} stopped!", p2p.settings().node_id);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|