Skip to content

Commit f4726a2

Browse files
committed
test: Use port range below Linux ephemeral range to avoid collisions
Restrict the random base port to 10000-30000, which is below the Linux ephemeral port range (32768-60999). This prevents collisions with OS-assigned ports used by electrsd and bitcoind. AI tools were used in preparing this commit.
1 parent 6153551 commit f4726a2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/common/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ static NEXT_PORT: AtomicU16 = AtomicU16::new(0);
278278

279279
fn init_base_port() {
280280
// Initialize once with a random base port. compare_exchange ensures only one thread wins.
281-
let base = rng().random_range(10000..50000u16);
281+
// Use a range below the Linux ephemeral port range (32768-60999) to avoid
282+
// collisions with OS-assigned ports used by electrsd/bitcoind.
283+
let base = rng().random_range(10000..30000u16);
282284
let _ = NEXT_PORT.compare_exchange(0, base, Ordering::Relaxed, Ordering::Relaxed);
283285
}
284286

0 commit comments

Comments
 (0)