Skip to content

Commit

Permalink
Re-org source tree to add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pool2win committed Oct 2, 2024
1 parent a9c5309 commit 3fcbf10
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod cli;
pub mod config;
pub mod node;
14 changes: 3 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@

use clap::Parser;
use std::error::Error;
use tokio::sync::broadcast;
use tokio_util::bytes::Bytes;

mod cli;
mod config;
mod node;
use frost_federation::cli;
use frost_federation::config;
use frost_federation::node;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
Expand All @@ -35,12 +33,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
setup_logging()?;
setup_tracing()?;

// let manager = Arc::new(ConnectionManager::new(config.peer.max_peer_count));

let (send_to_all_tx, _) = broadcast::channel::<Bytes>(config.peer.max_pending_send_to_all);
let _connect_broadcast_sender = send_to_all_tx.clone();
let _listen_broadcast_sender = send_to_all_tx.clone();

let mut node = node::Node::new()
.await
.seeds(config.peer.seeds)
Expand Down
2 changes: 1 addition & 1 deletion src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct Node {
pub bind_address: String,
pub static_key_pem: String,
pub delivery_timeout: u64,
pub state: State,
pub(crate) state: State,
}

impl Node {
Expand Down
24 changes: 24 additions & 0 deletions tests/run_nodes_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use frost_federation::config;
use frost_federation::node;

#[test]
fn test_start_a_single_node_should_complete_without_error() {
use tokio::time::{timeout, Duration};
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(async {
let config = config::load_config_from_file("config.run".to_string()).unwrap();
let bind_address = config::get_bind_address(config.network);

let mut node = node::Node::new()
.await
.seeds(config.peer.seeds)
.bind_address(bind_address)
.static_key_pem(config.noise.key)
.delivery_timeout(config.peer.delivery_timeout);

let _ = timeout(Duration::from_millis(10), node.start()).await;
});
}

0 comments on commit 3fcbf10

Please sign in to comment.