Skip to content

Commit d526f07

Browse files
committed
Initialize the USED_PORTS with the EVENT_OBSERVER_PORT
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent cc89b14 commit d526f07

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

testnet/stacks-node/src/tests/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ lazy_static! {
101101
}
102102

103103
lazy_static! {
104-
static ref USED_PORTS: Mutex<HashSet<u16>> = Mutex::new(HashSet::new());
104+
static ref USED_PORTS: Mutex<HashSet<u16>> = Mutex::new({
105+
let mut set = HashSet::new();
106+
set.insert(EVENT_OBSERVER_PORT);
107+
set
108+
});
105109
}
106110

107111
/// Generate a random port number between 1024 and 65534 (inclusive) and insert it into the USED_PORTS set.
@@ -116,9 +120,6 @@ pub fn gen_random_port() -> u16 {
116120
"No more available ports"
117121
);
118122
let port = rng.gen_range(1024..u16::MAX); // use a non-privileged port between 1024 and 65534
119-
if port == EVENT_OBSERVER_PORT {
120-
continue;
121-
}
122123
if insert_new_port(port) {
123124
return port;
124125
}

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ use stacks_signer::chainstate::{ProposalEvalConfig, SortitionsView};
9191
use stacks_signer::signerdb::{BlockInfo, BlockState, ExtraBlockInfo, SignerDb};
9292

9393
use super::bitcoin_regtest::BitcoinCoreController;
94-
use crate::config::{EventKeyType, EventObserverConfig, InitialBalance};
94+
use crate::config::{EventKeyType, InitialBalance};
9595
use crate::nakamoto_node::miner::{
9696
TEST_BLOCK_ANNOUNCE_STALL, TEST_BROADCAST_STALL, TEST_MINE_STALL, TEST_SKIP_P2P_BROADCAST,
9797
};

0 commit comments

Comments
 (0)