File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -333,3 +333,33 @@ fn do_connection_restart_behavior(persist: bool) {
333
333
assert ! ( node_b. list_peers( ) . is_empty( ) ) ;
334
334
}
335
335
}
336
+
337
+ #[ test]
338
+ fn concurrent_connections_succeed ( ) {
339
+ let ( _bitcoind, electrsd) = setup_bitcoind_and_electrsd ( ) ;
340
+ let ( node_a, node_b) = setup_two_nodes ( & electrsd, false ) ;
341
+
342
+ let node_a = Arc :: new ( node_a) ;
343
+ let node_b = Arc :: new ( node_b) ;
344
+
345
+ let node_id_b = node_b. node_id ( ) ;
346
+ let node_addr_b = node_b. listening_addresses ( ) . unwrap ( ) . first ( ) . unwrap ( ) . clone ( ) ;
347
+
348
+ while !node_b. status ( ) . is_listening {
349
+ std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 10 ) ) ;
350
+ }
351
+
352
+ let mut handles = Vec :: new ( ) ;
353
+ for _ in 0 ..10 {
354
+ let thread_node = Arc :: clone ( & node_a) ;
355
+ let thread_addr = node_addr_b. clone ( ) ;
356
+ let handle = std:: thread:: spawn ( move || {
357
+ thread_node. connect ( node_id_b, thread_addr, false ) . unwrap ( ) ;
358
+ } ) ;
359
+ handles. push ( handle) ;
360
+ }
361
+
362
+ for h in handles {
363
+ h. join ( ) . unwrap ( ) ;
364
+ }
365
+ }
You can’t perform that action at this time.
0 commit comments