Skip to content

Commit

Permalink
Merge pull request #8 from artemijan/fb-tests
Browse files Browse the repository at this point in the history
More unit tests
  • Loading branch information
artemijan authored Feb 22, 2025
2 parents 9ef5c80 + 1bd680a commit 95ee86d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion l2-core/src/traits/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ mod tests {
use std::fmt::{Debug, Formatter};
use std::net::Ipv4Addr;
use std::sync::Arc;
use std::time::Duration;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::sync::{Mutex, Notify};
use tokio::time::timeout;

struct MockServer;
struct MockController;
Expand Down Expand Up @@ -335,14 +337,19 @@ mod tests {
assert!(pool.ping().await.is_ok());
});
}

#[test]
fn test_listener() {
//this is just a simple check if we can bind to local host on port 2106
// after it's bind, we just simply abort the task.
MockServer::bootstrap("", |cfg, pool| async move {
let l_loop =
MockServer::listener_loop::<MockHandler>(cfg, Arc::new(MockController), pool);
l_loop.abort();
let result = timeout(Duration::from_secs(1), l_loop).await;

if let Err(e) = result {
assert_eq!(e.to_string(), "deadline has elapsed");
}
});
}
}

0 comments on commit 95ee86d

Please sign in to comment.