mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-22 03:30:38 +00:00
Fix AddrInUse
error in cli tests (#5266)
* Fix `AddrInUse` error in cli tests.
This commit is contained in:
parent
641f6be3f0
commit
762dab23b8
@ -23,8 +23,11 @@ use types::{
|
|||||||
Address, Checkpoint, Epoch, ExecutionBlockHash, ForkName, Hash256, MainnetEthSpec,
|
Address, Checkpoint, Epoch, ExecutionBlockHash, ForkName, Hash256, MainnetEthSpec,
|
||||||
ProgressiveBalancesMode,
|
ProgressiveBalancesMode,
|
||||||
};
|
};
|
||||||
|
use unused_port::{unused_tcp4_port, unused_tcp6_port, unused_udp4_port, unused_udp6_port};
|
||||||
|
|
||||||
const DEFAULT_ETH1_ENDPOINT: &str = "http://localhost:8545/";
|
const DEFAULT_ETH1_ENDPOINT: &str = "http://localhost:8545/";
|
||||||
|
|
||||||
|
// These dummy ports should ONLY be used for `enr-xxx-port` flags that do not bind.
|
||||||
const DUMMY_ENR_TCP_PORT: u16 = 7777;
|
const DUMMY_ENR_TCP_PORT: u16 = 7777;
|
||||||
const DUMMY_ENR_UDP_PORT: u16 = 8888;
|
const DUMMY_ENR_UDP_PORT: u16 = 8888;
|
||||||
const DUMMY_ENR_QUIC_PORT: u16 = 9999;
|
const DUMMY_ENR_QUIC_PORT: u16 = 9999;
|
||||||
@ -891,7 +894,7 @@ fn network_port_flag_over_ipv4() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let port = 9000;
|
let port = unused_tcp4_port().expect("Unable to find unused port.");
|
||||||
CommandLineTest::new()
|
CommandLineTest::new()
|
||||||
.flag("port", Some(port.to_string().as_str()))
|
.flag("port", Some(port.to_string().as_str()))
|
||||||
.flag("allow-insecure-genesis-sync", None)
|
.flag("allow-insecure-genesis-sync", None)
|
||||||
@ -928,7 +931,7 @@ fn network_port_flag_over_ipv6() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let port = 9000;
|
let port = unused_tcp4_port().expect("Unable to find unused port.");
|
||||||
CommandLineTest::new()
|
CommandLineTest::new()
|
||||||
.flag("listen-address", Some("::1"))
|
.flag("listen-address", Some("::1"))
|
||||||
.flag("port", Some(port.to_string().as_str()))
|
.flag("port", Some(port.to_string().as_str()))
|
||||||
@ -978,8 +981,8 @@ fn network_port_flag_over_ipv4_and_ipv6() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let port = 19000;
|
let port = unused_tcp4_port().expect("Unable to find unused port.");
|
||||||
let port6 = 29000;
|
let port6 = unused_tcp6_port().expect("Unable to find unused port.");
|
||||||
CommandLineTest::new()
|
CommandLineTest::new()
|
||||||
.flag("listen-address", Some("127.0.0.1"))
|
.flag("listen-address", Some("127.0.0.1"))
|
||||||
.flag("listen-address", Some("::1"))
|
.flag("listen-address", Some("::1"))
|
||||||
@ -1320,9 +1323,8 @@ fn enr_tcp6_port_flag() {
|
|||||||
fn enr_match_flag_over_ipv4() {
|
fn enr_match_flag_over_ipv4() {
|
||||||
let addr = "127.0.0.2".parse::<Ipv4Addr>().unwrap();
|
let addr = "127.0.0.2".parse::<Ipv4Addr>().unwrap();
|
||||||
|
|
||||||
// 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).
|
let udp4_port = unused_udp4_port().expect("Unable to find unused port.");
|
||||||
let udp4_port = DUMMY_ENR_UDP_PORT;
|
let tcp4_port = unused_tcp4_port().expect("Unable to find unused port.");
|
||||||
let tcp4_port = DUMMY_ENR_TCP_PORT;
|
|
||||||
|
|
||||||
CommandLineTest::new()
|
CommandLineTest::new()
|
||||||
.flag("enr-match", None)
|
.flag("enr-match", None)
|
||||||
@ -1352,9 +1354,8 @@ fn enr_match_flag_over_ipv6() {
|
|||||||
const ADDR: &str = "::1";
|
const ADDR: &str = "::1";
|
||||||
let addr = ADDR.parse::<Ipv6Addr>().unwrap();
|
let addr = ADDR.parse::<Ipv6Addr>().unwrap();
|
||||||
|
|
||||||
// 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).
|
let udp6_port = unused_udp6_port().expect("Unable to find unused port.");
|
||||||
let udp6_port = DUMMY_ENR_UDP_PORT;
|
let tcp6_port = unused_tcp6_port().expect("Unable to find unused port.");
|
||||||
let tcp6_port = DUMMY_ENR_TCP_PORT;
|
|
||||||
|
|
||||||
CommandLineTest::new()
|
CommandLineTest::new()
|
||||||
.flag("enr-match", None)
|
.flag("enr-match", None)
|
||||||
@ -1383,15 +1384,13 @@ fn enr_match_flag_over_ipv6() {
|
|||||||
fn enr_match_flag_over_ipv4_and_ipv6() {
|
fn enr_match_flag_over_ipv4_and_ipv6() {
|
||||||
const IPV6_ADDR: &str = "::1";
|
const IPV6_ADDR: &str = "::1";
|
||||||
|
|
||||||
// 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).
|
let udp6_port = unused_udp6_port().expect("Unable to find unused port.");
|
||||||
let udp6_port = DUMMY_ENR_UDP_PORT;
|
let tcp6_port = unused_tcp6_port().expect("Unable to find unused port.");
|
||||||
let tcp6_port = DUMMY_ENR_TCP_PORT;
|
|
||||||
let ipv6_addr = IPV6_ADDR.parse::<Ipv6Addr>().unwrap();
|
let ipv6_addr = IPV6_ADDR.parse::<Ipv6Addr>().unwrap();
|
||||||
|
|
||||||
const IPV4_ADDR: &str = "127.0.0.1";
|
const IPV4_ADDR: &str = "127.0.0.1";
|
||||||
// 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).
|
let udp4_port = unused_udp4_port().expect("Unable to find unused port.");
|
||||||
let udp4_port = DUMMY_ENR_UDP_PORT;
|
let tcp4_port = unused_tcp4_port().expect("Unable to find unused port.");
|
||||||
let tcp4_port = DUMMY_ENR_TCP_PORT;
|
|
||||||
let ipv4_addr = IPV4_ADDR.parse::<Ipv4Addr>().unwrap();
|
let ipv4_addr = IPV4_ADDR.parse::<Ipv4Addr>().unwrap();
|
||||||
|
|
||||||
CommandLineTest::new()
|
CommandLineTest::new()
|
||||||
|
Loading…
Reference in New Issue
Block a user