Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma233 committed Sep 3, 2023
1 parent d373425 commit 1225463
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions core/src/tests/default/test_message_handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::str::FromStr;

use rings_transport::core::transport::SharedConnection;
use rings_transport::core::transport::WebrtcConnectionState;
use tokio::time::sleep;
use tokio::time::Duration;

Expand Down Expand Up @@ -108,12 +109,12 @@ async fn test_handle_connect_node() -> Result<()> {
}

assert_eq!(
format!("{:?}", connection_1_to_2.ice_connection_state()),
"connected"
connection_1_to_2.ice_connection_state(),
WebrtcConnectionState::Connected,
);
assert_eq!(
format!("{:?}", connection_2_to_3.ice_connection_state()),
"connected"
connection_2_to_3.ice_connection_state(),
WebrtcConnectionState::Connected,
);

// node1.dht() send msg to node2.dht() ask for connecting node3.dht()
Expand All @@ -124,14 +125,14 @@ async fn test_handle_connect_node() -> Result<()> {
assert!(connection_1_to_3.is_some());
let connection_1_to_3 = connection_1_to_3.unwrap();
let both = {
format!("{:?}", connection_1_to_3.ice_connection_state()) == "new" ||
format!("{:?}",connection_1_to_3.ice_connection_state()) == "checking" ||
format!("{:?}",connection_1_to_3.ice_connection_state()) == "connected"
connection_1_to_3.ice_connection_state() == WebrtcConnectionState::New ||
connection_1_to_3.ice_connection_state() == WebrtcConnectionState::Connecting ||
connection_1_to_3.ice_connection_state() == WebrtcConnectionState::Connected
};
assert!(both, "{:?}", connection_1_to_3.ice_connection_state());
assert_eq!(
format!("{:?}", connection_1_to_3.ice_connection_state()),
"connected"
connection_1_to_3.ice_connection_state(),
WebrtcConnectionState::Connected
);
Ok::<(), Error>(())
} => {}
Expand Down Expand Up @@ -169,7 +170,7 @@ async fn test_handle_notify_predecessor() -> Result<()> {
sleep(Duration::from_millis(1000)).await;
assert!(node1.dht().successors().list()?.contains(&key2.address().into()));
assert!(node2.dht().successors().list()?.contains(&key1.address().into()));
assert_eq!(format!("{:?}", connection_1_to_2.ice_connection_state()), "connected");
assert_eq!(connection_1_to_2.ice_connection_state(), WebrtcConnectionState::Connected);
node1
.send_message(
Message::NotifyPredecessorSend(message::NotifyPredecessorSend {
Expand Down Expand Up @@ -221,7 +222,7 @@ async fn test_handle_find_successor_increase() -> Result<()> {
sleep(Duration::from_millis(1000)).await;
assert!(node1.dht().successors().list()?.contains(&key2.address().into()), "{:?}", node1.dht().successors().list()?);
assert!(node2.dht().successors().list()?.contains(&key1.address().into()));
assert_eq!(format!("{:?}", connection_1_to_2.ice_connection_state()), "connected");
assert_eq!(connection_1_to_2.ice_connection_state(), WebrtcConnectionState::Connected);
node1
.send_message(
Message::NotifyPredecessorSend(message::NotifyPredecessorSend {
Expand Down Expand Up @@ -300,10 +301,7 @@ async fn test_handle_find_successor_decrease() -> Result<()> {
assert!(node2.dht()
.lock_finger()?
.contains(Some(key1.address().into())));
assert_eq!(
format!("{:?}", connection_1_to_2.ice_connection_state()),
"connected"
);
assert_eq!(connection_1_to_2.ice_connection_state(), WebrtcConnectionState::Connected);
node1
.send_message(
Message::NotifyPredecessorSend(message::NotifyPredecessorSend {
Expand Down Expand Up @@ -383,8 +381,8 @@ async fn test_handle_storage() -> Result<()> {
.list()?
.contains(&key1.address().into()));
assert_eq!(
format!("{:?}", connection_1_to_2.ice_connection_state()),
"connected"
connection_1_to_2.ice_connection_state(),
WebrtcConnectionState::Connected
);
node1
.send_message(
Expand Down

0 comments on commit 1225463

Please sign in to comment.