File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -327,3 +327,31 @@ fn do_connection_restart_behavior(persist: bool) {
327
327
assert ! ( node_b. list_peers( ) . is_empty( ) ) ;
328
328
}
329
329
}
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
+ }
You can’t perform that action at this time.
0 commit comments