@@ -145,7 +145,8 @@ impl BitcoinD {
145
145
let p2p_socket = SocketAddrV4 :: new ( LOCAL_IP , p2p_port) ;
146
146
let p2p_arg = format ! ( "-port={}" , p2p_port) ;
147
147
let connect = format ! ( "-connect={}" , other_node_url) ;
148
- let args = vec ! [ p2p_arg, connect] ;
148
+ let listen = "-listen=1" . to_string ( ) ; // With connect specified listen is not defaulted to 1
149
+ let args = vec ! [ p2p_arg, connect, listen] ;
149
150
( args, Some ( p2p_socket) )
150
151
}
151
152
} ;
@@ -336,8 +337,40 @@ mod test {
336
337
assert_eq ! ( other_bitcoind. client. get_peer_info( ) . unwrap( ) . len( ) , 1 ) ;
337
338
}
338
339
339
- fn init ( ) -> String {
340
- let _ = env_logger:: try_init ( ) ;
340
+ #[ test]
341
+ fn test_multi_p2p ( ) {
342
+ let conf_node1 = Conf {
343
+ p2p : P2P :: Yes ,
344
+ ..Default :: default ( )
345
+ } ;
346
+ let node1 = BitcoinD :: with_conf ( exe_path ( ) , & conf_node1) . unwrap ( ) ;
347
+
348
+ // Create Node 2 connected Node 1
349
+ let conf_node2 = Conf {
350
+ p2p : node1. p2p_connect ( ) . unwrap ( ) ,
351
+ ..Default :: default ( )
352
+ } ;
353
+ let node2 = BitcoinD :: with_conf ( exe_path ( ) , & conf_node2) . unwrap ( ) ;
354
+
355
+ // Create Node 3 Connected To Node 2
356
+ let conf_node3 = Conf {
357
+ p2p : node2. p2p_connect ( ) . unwrap ( ) ,
358
+ ..Default :: default ( )
359
+ } ;
360
+ let node3 = BitcoinD :: with_conf ( exe_path ( ) , & conf_node3) . unwrap ( ) ;
361
+
362
+ // Get each nodes Peers
363
+ let node1_peers = node1. client . get_peer_info ( ) . unwrap ( ) ;
364
+ let node2_peers = node2. client . get_peer_info ( ) . unwrap ( ) ;
365
+ let node3_peers = node3. client . get_peer_info ( ) . unwrap ( ) ;
366
+
367
+ // Peers found
368
+ assert ! ( node1_peers. len( ) >= 1 ) ;
369
+ assert ! ( node2_peers. len( ) >= 1 ) ;
370
+ assert ! ( node3_peers. len( ) >= 1 ) ;
371
+ }
372
+
373
+ fn exe_path ( ) -> String {
341
374
if let Some ( downloaded_exe_path) = downloaded_exe_path ( ) {
342
375
downloaded_exe_path
343
376
} else {
@@ -346,4 +379,9 @@ mod test {
346
379
)
347
380
}
348
381
}
382
+
383
+ fn init ( ) -> String {
384
+ let _ = env_logger:: try_init ( ) ;
385
+ exe_path ( )
386
+ }
349
387
}
0 commit comments