@@ -12,7 +12,7 @@ use clarity::vm::costs::ExecutionCost;
12
12
use clarity:: vm:: types:: serialization:: SerializationError ;
13
13
use clarity:: vm:: types:: PrincipalData ;
14
14
use clarity:: vm:: { ClarityName , ClarityVersion , ContractName , Value , MAX_CALL_STACK_DEPTH } ;
15
- use rand:: { Rng , RngCore } ;
15
+ use rand:: Rng ;
16
16
use rusqlite:: params;
17
17
use serde:: Deserialize ;
18
18
use serde_json:: json;
@@ -986,7 +986,16 @@ fn bitcoind_integration_test() {
986
986
}
987
987
988
988
let ( mut conf, miner_account) = neon_integration_test_conf ( ) ;
989
- let prom_bind = format ! ( "{}:{}" , "127.0.0.1" , 6000 ) ;
989
+ let localhost = "127.0.0.1" ;
990
+ let mut rng = rand:: thread_rng ( ) ;
991
+ // Use a non-privileged port between 1024 and 65534
992
+ let mut prom_port = 6000 ;
993
+ let mut prom_bind = format ! ( "{localhost}:{prom_port}" ) ;
994
+ while prom_bind == conf. node . rpc_bind || prom_bind == conf. node . p2p_bind {
995
+ // We should NOT match the miner's rpc or p2p binds
996
+ prom_port = rng. gen_range ( 1024 ..65533 ) ;
997
+ prom_bind = format ! ( "{localhost}:{prom_port}" ) ;
998
+ }
990
999
conf. node . prometheus_bind = Some ( prom_bind. clone ( ) ) ;
991
1000
992
1001
conf. burnchain . max_rbf = 1000000 ;
@@ -12466,18 +12475,21 @@ fn bitcoin_reorg_flap_with_follower() {
12466
12475
follower_conf. node . seed = vec ! [ 0x01 ; 32 ] ;
12467
12476
follower_conf. node . local_peer_seed = vec ! [ 0x02 ; 32 ] ;
12468
12477
12478
+ let localhost = "127.0.0.1" ;
12469
12479
let mut rng = rand:: thread_rng ( ) ;
12470
- let mut buf = [ 0u8 ; 8 ] ;
12471
- rng. fill_bytes ( & mut buf) ;
12472
-
12473
- let rpc_port = u16:: from_be_bytes ( buf[ 0 ..2 ] . try_into ( ) . unwrap ( ) ) . saturating_add ( 1025 ) - 1 ; // use a non-privileged port between 1024 and 65534
12474
- let p2p_port = u16:: from_be_bytes ( buf[ 2 ..4 ] . try_into ( ) . unwrap ( ) ) . saturating_add ( 1025 ) - 1 ; // use a non-privileged port between 1024 and 65534
12480
+ // Use a non-privileged port between 1024 and 65534
12481
+ let mut rpc_port: u16 = rng. gen_range ( 1024 ..65533 ) ;
12482
+ while format ! ( "{localhost}:{rpc_port}" ) == conf. node . rpc_bind {
12483
+ // We should NOT match the miner's rpc bind and subsequently p2p port
12484
+ rpc_port = rng. gen_range ( 1024 ..65533 ) ;
12485
+ }
12486
+ let p2p_port = rpc_port + 1 ;
12475
12487
12476
- let localhost = "127.0.0.1" ;
12477
- follower_conf. node . rpc_bind = format ! ( "{}:{}" , & localhost , rpc_port ) ;
12478
- follower_conf. node . p2p_bind = format ! ( "{ }:{}" , & localhost , p2p_port ) ;
12479
- follower_conf. node . data_url = format ! ( "http://{ }:{}" , & localhost , rpc_port ) ;
12480
- follower_conf. node . p2p_address = format ! ( "{}:{}" , & localhost , p2p_port ) ;
12488
+ follower_conf . node . rpc_bind = format ! ( "{localhost}:{rpc_port}" ) ;
12489
+ follower_conf. node . p2p_bind = format ! ( "{localhost }:{p2p_port}" ) ;
12490
+ follower_conf. node . data_url = format ! ( "http://{localhost }:{rpc_port}" ) ;
12491
+ follower_conf. node . p2p_address = format ! ( "{localhost }:{p2p_port}" ) ;
12492
+ follower_conf. node . pox_sync_sample_secs = 30 ;
12481
12493
12482
12494
let run_loop_thread = thread:: spawn ( move || miner_run_loop. start ( None , 0 ) ) ;
12483
12495
wait_for_runloop ( & miner_blocks_processed) ;
@@ -12800,7 +12812,16 @@ fn listunspent_max_utxos() {
12800
12812
}
12801
12813
12802
12814
let ( mut conf, _miner_account) = neon_integration_test_conf ( ) ;
12803
- let prom_bind = format ! ( "{}:{}" , "127.0.0.1" , 6000 ) ;
12815
+ let localhost = "127.0.0.1" ;
12816
+ let mut rng = rand:: thread_rng ( ) ;
12817
+ // Use a non-privileged port between 1024 and 65534
12818
+ let mut prom_port = 6000 ;
12819
+ let mut prom_bind = format ! ( "{localhost}:{prom_port}" ) ;
12820
+ while prom_bind == conf. node . rpc_bind || prom_bind == conf. node . p2p_bind {
12821
+ // We should NOT match the miner's rpc or p2p binds
12822
+ prom_port = rng. gen_range ( 1024 ..65533 ) ;
12823
+ prom_bind = format ! ( "{localhost}:{prom_port}" ) ;
12824
+ }
12804
12825
conf. node . prometheus_bind = Some ( prom_bind. clone ( ) ) ;
12805
12826
12806
12827
conf. burnchain . max_rbf = 1000000 ;
@@ -12846,7 +12867,16 @@ fn start_stop_bitcoind() {
12846
12867
}
12847
12868
12848
12869
let ( mut conf, _miner_account) = neon_integration_test_conf ( ) ;
12849
- let prom_bind = format ! ( "{}:{}" , "127.0.0.1" , 6000 ) ;
12870
+ let localhost = "127.0.0.1" ;
12871
+ let mut rng = rand:: thread_rng ( ) ;
12872
+ // Use a non-privileged port between 1024 and 65534
12873
+ let mut prom_port = 6000 ;
12874
+ let mut prom_bind = format ! ( "{localhost}:{prom_port}" ) ;
12875
+ while prom_bind == conf. node . rpc_bind || prom_bind == conf. node . p2p_bind {
12876
+ // We should NOT match the miner's rpc or p2p binds
12877
+ prom_port = rng. gen_range ( 1024 ..65533 ) ;
12878
+ prom_bind = format ! ( "{localhost}:{prom_port}" ) ;
12879
+ }
12850
12880
conf. node . prometheus_bind = Some ( prom_bind. clone ( ) ) ;
12851
12881
12852
12882
conf. burnchain . max_rbf = 1000000 ;
0 commit comments