@@ -986,16 +986,31 @@ fn bitcoind_integration_test() {
986
986
}
987
987
988
988
let ( mut conf, miner_account) = neon_integration_test_conf ( ) ;
989
- let localhost = "127.0.0.1" ;
990
989
let mut rng = rand:: thread_rng ( ) ;
991
- // Use a non-privileged port between 1024 and 65534
992
990
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 {
991
+ let prior_rpc_port: u16 = conf
992
+ . node
993
+ . rpc_bind
994
+ . split ( ":" )
995
+ . last ( )
996
+ . unwrap ( )
997
+ . parse ( )
998
+ . unwrap ( ) ;
999
+ let prior_p2p_port: u16 = conf
1000
+ . node
1001
+ . p2p_bind
1002
+ . split ( ":" )
1003
+ . last ( )
1004
+ . unwrap ( )
1005
+ . parse ( )
1006
+ . unwrap ( ) ;
1007
+ // Use a non-privileged port between 1024 and 65534
1008
+ while prom_port == prior_rpc_port || prom_port == prior_p2p_port {
995
1009
// 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}" ) ;
1010
+ prom_port = rng. gen_range ( 1024 ..u16:: MAX ) ;
998
1011
}
1012
+ let localhost = "127.0.0.1" ;
1013
+ let prom_bind = format ! ( "{localhost}:{prom_port}" ) ;
999
1014
conf. node . prometheus_bind = Some ( prom_bind. clone ( ) ) ;
1000
1015
1001
1016
conf. burnchain . max_rbf = 1000000 ;
@@ -12475,16 +12490,37 @@ fn bitcoin_reorg_flap_with_follower() {
12475
12490
follower_conf. node . seed = vec ! [ 0x01 ; 32 ] ;
12476
12491
follower_conf. node . local_peer_seed = vec ! [ 0x02 ; 32 ] ;
12477
12492
12478
- let localhost = "127.0.0.1" ;
12479
12493
let mut rng = rand:: thread_rng ( ) ;
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 ;
12494
+ let prior_rpc_port: u16 = conf
12495
+ . node
12496
+ . rpc_bind
12497
+ . split ( ":" )
12498
+ . last ( )
12499
+ . unwrap ( )
12500
+ . parse ( )
12501
+ . unwrap ( ) ;
12502
+ let prior_p2p_port: u16 = conf
12503
+ . node
12504
+ . p2p_bind
12505
+ . split ( ":" )
12506
+ . last ( )
12507
+ . unwrap ( )
12508
+ . parse ( )
12509
+ . unwrap ( ) ;
12510
+ let ( rpc_port, p2p_port) = loop {
12511
+ let a = rng. gen_range ( 1024 ..u16:: MAX ) ; // use a non-privileged port between 1024 and 65534
12512
+ let b = rng. gen_range ( 1024 ..u16:: MAX ) ; // use a non-privileged port between 1024 and 65534
12513
+ if a != b
12514
+ && a != prior_rpc_port
12515
+ && a != prior_p2p_port
12516
+ && b != prior_rpc_port
12517
+ && b != prior_p2p_port
12518
+ {
12519
+ break ( a, b) ;
12520
+ }
12521
+ } ;
12487
12522
12523
+ let localhost = "127.0.0.1" ;
12488
12524
follower_conf. node . rpc_bind = format ! ( "{localhost}:{rpc_port}" ) ;
12489
12525
follower_conf. node . p2p_bind = format ! ( "{localhost}:{p2p_port}" ) ;
12490
12526
follower_conf. node . data_url = format ! ( "http://{localhost}:{rpc_port}" ) ;
@@ -12670,11 +12706,31 @@ fn mock_miner_replay() {
12670
12706
follower_conf. node . local_peer_seed = vec ! [ 0x02 ; 32 ] ;
12671
12707
12672
12708
let mut rng = rand:: thread_rng ( ) ;
12673
-
12709
+ let prior_rpc_port: u16 = conf
12710
+ . node
12711
+ . rpc_bind
12712
+ . split ( ":" )
12713
+ . last ( )
12714
+ . unwrap ( )
12715
+ . parse ( )
12716
+ . unwrap ( ) ;
12717
+ let prior_p2p_port: u16 = conf
12718
+ . node
12719
+ . p2p_bind
12720
+ . split ( ":" )
12721
+ . last ( )
12722
+ . unwrap ( )
12723
+ . parse ( )
12724
+ . unwrap ( ) ;
12674
12725
let ( rpc_port, p2p_port) = loop {
12675
12726
let a = rng. gen_range ( 1024 ..u16:: MAX ) ; // use a non-privileged port between 1024 and 65534
12676
12727
let b = rng. gen_range ( 1024 ..u16:: MAX ) ; // use a non-privileged port between 1024 and 65534
12677
- if a != b {
12728
+ if a != b
12729
+ && a != prior_rpc_port
12730
+ && a != prior_p2p_port
12731
+ && b != prior_rpc_port
12732
+ && b != prior_p2p_port
12733
+ {
12678
12734
break ( a, b) ;
12679
12735
}
12680
12736
} ;
@@ -12812,16 +12868,31 @@ fn listunspent_max_utxos() {
12812
12868
}
12813
12869
12814
12870
let ( mut conf, _miner_account) = neon_integration_test_conf ( ) ;
12815
- let localhost = "127.0.0.1" ;
12816
12871
let mut rng = rand:: thread_rng ( ) ;
12817
- // Use a non-privileged port between 1024 and 65534
12818
12872
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 {
12873
+ let prior_rpc_port: u16 = conf
12874
+ . node
12875
+ . rpc_bind
12876
+ . split ( ":" )
12877
+ . last ( )
12878
+ . unwrap ( )
12879
+ . parse ( )
12880
+ . unwrap ( ) ;
12881
+ let prior_p2p_port: u16 = conf
12882
+ . node
12883
+ . p2p_bind
12884
+ . split ( ":" )
12885
+ . last ( )
12886
+ . unwrap ( )
12887
+ . parse ( )
12888
+ . unwrap ( ) ;
12889
+ // Use a non-privileged port between 1024 and 65534
12890
+ while prom_port == prior_rpc_port || prom_port == prior_p2p_port {
12821
12891
// 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}" ) ;
12892
+ prom_port = rng. gen_range ( 1024 ..u16:: MAX ) ;
12824
12893
}
12894
+ let localhost = "127.0.0.1" ;
12895
+ let prom_bind = format ! ( "{localhost}:{prom_port}" ) ;
12825
12896
conf. node . prometheus_bind = Some ( prom_bind. clone ( ) ) ;
12826
12897
12827
12898
conf. burnchain . max_rbf = 1000000 ;
@@ -12867,16 +12938,31 @@ fn start_stop_bitcoind() {
12867
12938
}
12868
12939
12869
12940
let ( mut conf, _miner_account) = neon_integration_test_conf ( ) ;
12870
- let localhost = "127.0.0.1" ;
12871
12941
let mut rng = rand:: thread_rng ( ) ;
12872
- // Use a non-privileged port between 1024 and 65534
12873
12942
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 {
12943
+ let prior_rpc_port: u16 = conf
12944
+ . node
12945
+ . rpc_bind
12946
+ . split ( ":" )
12947
+ . last ( )
12948
+ . unwrap ( )
12949
+ . parse ( )
12950
+ . unwrap ( ) ;
12951
+ let prior_p2p_port: u16 = conf
12952
+ . node
12953
+ . p2p_bind
12954
+ . split ( ":" )
12955
+ . last ( )
12956
+ . unwrap ( )
12957
+ . parse ( )
12958
+ . unwrap ( ) ;
12959
+ // Use a non-privileged port between 1024 and 65534
12960
+ while prom_port == prior_rpc_port || prom_port == prior_p2p_port {
12876
12961
// 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}" ) ;
12962
+ prom_port = rng. gen_range ( 1024 ..u16:: MAX ) ;
12879
12963
}
12964
+ let localhost = "127.0.0.1" ;
12965
+ let prom_bind = format ! ( "{localhost}:{prom_port}" ) ;
12880
12966
conf. node . prometheus_bind = Some ( prom_bind. clone ( ) ) ;
12881
12967
12882
12968
conf. burnchain . max_rbf = 1000000 ;
0 commit comments