aboutsummaryrefslogtreecommitdiff
path: root/src/test.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-13 18:07:34 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-13 18:07:34 +0200
commite0c63415d3c437c33f67c9855f3e90e15388af00 (patch)
tree052dfe14dd162c41aade25ff79c6b6a3dd8125cb /src/test.rs
parentabaff96f7deab09d4e2e59bbbd1e265837a9afbe (diff)
downloadnetapp-e0c63415d3c437c33f67c9855f3e90e15388af00.tar.gz
netapp-e0c63415d3c437c33f67c9855f3e90e15388af00.zip
Fix cargo fmt
Diffstat (limited to 'src/test.rs')
-rw-r--r--src/test.rs38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/test.rs b/src/test.rs
index e4ec495..402e891 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -1,6 +1,6 @@
use std::net::SocketAddr;
-use std::sync::{Arc};
-use std::time::{Duration};
+use std::sync::Arc;
+use std::time::Duration;
use tokio::select;
use tokio::sync::watch;
@@ -8,17 +8,16 @@ use tokio::sync::watch;
use sodiumoxide::crypto::auth;
use sodiumoxide::crypto::sign::ed25519;
-use crate::peering::fullmesh::*;
use crate::netapp::*;
+use crate::peering::fullmesh::*;
use crate::NodeID;
-
-#[tokio::test(flavor="current_thread")]
+#[tokio::test(flavor = "current_thread")]
async fn test_with_basic_scheduler() {
run_test().await
}
-#[tokio::test(flavor="multi_thread", worker_threads=4)]
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_with_threaded_scheduler() {
run_test().await
}
@@ -43,11 +42,19 @@ async fn run_test_inner() {
let (stop_tx, stop_rx) = watch::channel(false);
- let (thread1, _netapp1, peering1) = run_netapp(netid.clone(), pk1, sk1, addr1, vec![], stop_rx.clone());
+ let (thread1, _netapp1, peering1) =
+ run_netapp(netid.clone(), pk1, sk1, addr1, vec![], stop_rx.clone());
tokio::time::sleep(Duration::from_secs(2)).await;
// Connect second node and check it peers with everyone
- let (thread2, _netapp2, peering2) = run_netapp(netid.clone(), pk2, sk2, addr2, vec![(pk1, addr1)], stop_rx.clone());
+ let (thread2, _netapp2, peering2) = run_netapp(
+ netid.clone(),
+ pk2,
+ sk2,
+ addr2,
+ vec![(pk1, addr1)],
+ stop_rx.clone(),
+ );
tokio::time::sleep(Duration::from_secs(5)).await;
let pl1 = peering1.get_peer_list();
@@ -59,7 +66,8 @@ async fn run_test_inner() {
assert_eq!(pl2.len(), 2);
// Connect third ndoe and check it peers with everyone
- let (thread3, _netapp3, peering3) = run_netapp(netid, pk3, sk3, addr3, vec![(pk2, addr2)], stop_rx.clone());
+ let (thread3, _netapp3, peering3) =
+ run_netapp(netid, pk3, sk3, addr3, vec![(pk2, addr2)], stop_rx.clone());
tokio::time::sleep(Duration::from_secs(5)).await;
let pl1 = peering1.get_peer_list();
@@ -87,11 +95,12 @@ fn run_netapp(
sk: ed25519::SecretKey,
listen_addr: SocketAddr,
bootstrap_peers: Vec<(NodeID, SocketAddr)>,
- must_exit: watch::Receiver<bool>)
- ->
- (tokio::task::JoinHandle<()>, Arc<NetApp>, Arc<FullMeshPeeringStrategy>)
-{
-
+ must_exit: watch::Receiver<bool>,
+) -> (
+ tokio::task::JoinHandle<()>,
+ Arc<NetApp>,
+ Arc<FullMeshPeeringStrategy>,
+) {
let netapp = NetApp::new(netid, sk);
let peering = FullMeshPeeringStrategy::new(netapp.clone(), bootstrap_peers);
@@ -106,4 +115,3 @@ fn run_netapp(
(fut, netapp, peering)
}
-