Skip to content

Commit 6a901f3

Browse files
authored
Merge of #5266
2 parents f756997 + a54372e commit 6a901f3

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

lighthouse/tests/beacon_node.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ use types::{
2323
Address, Checkpoint, Epoch, ExecutionBlockHash, ForkName, Hash256, MainnetEthSpec,
2424
ProgressiveBalancesMode,
2525
};
26+
use unused_port::{unused_tcp4_port, unused_tcp6_port, unused_udp4_port, unused_udp6_port};
2627

2728
const DEFAULT_ETH1_ENDPOINT: &str = "http://localhost:8545/";
29+
30+
// These dummy ports should ONLY be used for `enr-xxx-port` flags that do not bind.
2831
const DUMMY_ENR_TCP_PORT: u16 = 7777;
2932
const DUMMY_ENR_UDP_PORT: u16 = 8888;
3033
const DUMMY_ENR_QUIC_PORT: u16 = 9999;
@@ -891,7 +894,7 @@ fn network_port_flag_over_ipv4() {
891894
);
892895
});
893896

894-
let port = 9000;
897+
let port = unused_tcp4_port().expect("Unable to find unused port.");
895898
CommandLineTest::new()
896899
.flag("port", Some(port.to_string().as_str()))
897900
.flag("allow-insecure-genesis-sync", None)
@@ -928,7 +931,7 @@ fn network_port_flag_over_ipv6() {
928931
);
929932
});
930933

931-
let port = 9000;
934+
let port = unused_tcp4_port().expect("Unable to find unused port.");
932935
CommandLineTest::new()
933936
.flag("listen-address", Some("::1"))
934937
.flag("port", Some(port.to_string().as_str()))
@@ -978,8 +981,8 @@ fn network_port_flag_over_ipv4_and_ipv6() {
978981
);
979982
});
980983

981-
let port = 19000;
982-
let port6 = 29000;
984+
let port = unused_tcp4_port().expect("Unable to find unused port.");
985+
let port6 = unused_tcp6_port().expect("Unable to find unused port.");
983986
CommandLineTest::new()
984987
.flag("listen-address", Some("127.0.0.1"))
985988
.flag("listen-address", Some("::1"))
@@ -1320,9 +1323,8 @@ fn enr_tcp6_port_flag() {
13201323
fn enr_match_flag_over_ipv4() {
13211324
let addr = "127.0.0.2".parse::<Ipv4Addr>().unwrap();
13221325

1323-
// the reason we use the ENR dummy values is because, due to the nature of the `--enr-match` flag, these will eventually become ENR ports (as well as listening ports).
1324-
let udp4_port = DUMMY_ENR_UDP_PORT;
1325-
let tcp4_port = DUMMY_ENR_TCP_PORT;
1326+
let udp4_port = unused_udp4_port().expect("Unable to find unused port.");
1327+
let tcp4_port = unused_tcp4_port().expect("Unable to find unused port.");
13261328

13271329
CommandLineTest::new()
13281330
.flag("enr-match", None)
@@ -1352,9 +1354,8 @@ fn enr_match_flag_over_ipv6() {
13521354
const ADDR: &str = "::1";
13531355
let addr = ADDR.parse::<Ipv6Addr>().unwrap();
13541356

1355-
// the reason we use the ENR dummy values is because, due to the nature of the `--enr-match` flag, these will eventually become ENR ports (as well as listening ports).
1356-
let udp6_port = DUMMY_ENR_UDP_PORT;
1357-
let tcp6_port = DUMMY_ENR_TCP_PORT;
1357+
let udp6_port = unused_udp6_port().expect("Unable to find unused port.");
1358+
let tcp6_port = unused_tcp6_port().expect("Unable to find unused port.");
13581359

13591360
CommandLineTest::new()
13601361
.flag("enr-match", None)
@@ -1383,15 +1384,13 @@ fn enr_match_flag_over_ipv6() {
13831384
fn enr_match_flag_over_ipv4_and_ipv6() {
13841385
const IPV6_ADDR: &str = "::1";
13851386

1386-
// the reason we use the ENR dummy values is because, due to the nature of the `--enr-match` flag, these will eventually become ENR ports (as well as listening ports).
1387-
let udp6_port = DUMMY_ENR_UDP_PORT;
1388-
let tcp6_port = DUMMY_ENR_TCP_PORT;
1387+
let udp6_port = unused_udp6_port().expect("Unable to find unused port.");
1388+
let tcp6_port = unused_tcp6_port().expect("Unable to find unused port.");
13891389
let ipv6_addr = IPV6_ADDR.parse::<Ipv6Addr>().unwrap();
13901390

13911391
const IPV4_ADDR: &str = "127.0.0.1";
1392-
// the reason we use the ENR dummy values is because, due to the nature of the `--enr-match` flag, these will eventually become ENR ports (as well as listening ports).
1393-
let udp4_port = DUMMY_ENR_UDP_PORT;
1394-
let tcp4_port = DUMMY_ENR_TCP_PORT;
1392+
let udp4_port = unused_udp4_port().expect("Unable to find unused port.");
1393+
let tcp4_port = unused_tcp4_port().expect("Unable to find unused port.");
13951394
let ipv4_addr = IPV4_ADDR.parse::<Ipv4Addr>().unwrap();
13961395

13971396
CommandLineTest::new()

0 commit comments

Comments
 (0)