MCPcopy Create free account
hub / github.com/ceramicnetwork/rust-ceramic / test_two_nodes

Function test_two_nodes

p2p/tests/node.rs:134–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

132
133#[test(tokio::test(flavor = "multi_thread", worker_threads = 2))]
134async fn test_two_nodes() -> Result<()> {
135 let mut test_runner_a = TestRunnerBuilder::new().build().await?;
136 let mut test_runner_b = TestRunnerBuilder::new().build().await?;
137 let addrs_b = vec![test_runner_b.addr.clone()];
138 debug!(?test_runner_a.peer_id, ?test_runner_b.peer_id, "peer ids");
139
140 let peer_id_a = test_runner_a.client.local_peer_id().await?;
141 assert_eq!(test_runner_a.peer_id, peer_id_a);
142 let peer_id_b = test_runner_b.client.local_peer_id().await?;
143 assert_eq!(test_runner_b.peer_id, peer_id_b);
144
145 // connect
146 test_runner_a.client.connect(peer_id_b, addrs_b).await?;
147
148 timeout(
149 Duration::from_millis(500),
150 wait_bi_connected(&mut test_runner_a, &mut test_runner_b),
151 )
152 .await
153 .context("waiting for a and b to connect")?;
154
155 assert!(is_bi_connected(&test_runner_a, &test_runner_b).await?);
156
157 Ok(())
158}
159
160#[test(tokio::test(flavor = "multi_thread", worker_threads = 2))]
161async fn test_three_nodes() -> Result<()> {

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
wait_bi_connectedFunction · 0.85
buildMethod · 0.45
local_peer_idMethod · 0.45
connectMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected