Skip to content

Commit c50a622

Browse files
committed
Add test for concurrent connection handling
... we check that we can successfully issue concurrent connection attempts, which all succeed.
1 parent 5cd220d commit c50a622

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/integration_tests_rust.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,31 @@ fn do_connection_restart_behavior(persist: bool) {
327327
assert!(node_b.list_peers().is_empty());
328328
}
329329
}
330+
331+
#[test]
332+
fn concurrent_connections_succeed() {
333+
let (_bitcoind, electrsd) = setup_bitcoind_and_electrsd();
334+
let (node_a, node_b) = setup_two_nodes(&electrsd, false);
335+
336+
let node_a = Arc::new(node_a);
337+
let node_b = Arc::new(node_b);
338+
339+
let node_id_b = node_b.node_id();
340+
let node_addr_b = node_b.listening_addresses().unwrap().first().unwrap().clone();
341+
342+
std::thread::sleep(std::time::Duration::from_secs(1));
343+
344+
let mut handles = Vec::new();
345+
for _ in 0..10 {
346+
let thread_node = Arc::clone(&node_a);
347+
let thread_addr = node_addr_b.clone();
348+
let handle = std::thread::spawn(move || {
349+
thread_node.connect(node_id_b, thread_addr, false).unwrap();
350+
});
351+
handles.push(handle);
352+
}
353+
354+
for h in handles {
355+
h.join().unwrap();
356+
}
357+
}

0 commit comments

Comments
 (0)