Skip to content

Commit dcf32b9

Browse files
committed
Hack to fix tests
1 parent 840c591 commit dcf32b9

File tree

3 files changed

+165
-3
lines changed

3 files changed

+165
-3
lines changed

Cargo.lock

Lines changed: 151 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

beacon_node/lighthouse_network/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fnv = { workspace = true }
2626
futures = { workspace = true }
2727
gossipsub = { workspace = true }
2828
hex = { workspace = true }
29-
if-watch = "3.2.1"
29+
if-watch = { version = "3.2.1", features = ["smol"] }
3030
itertools = { workspace = true }
3131
libp2p-mplex = "0.43"
3232
lighthouse_version = { workspace = true }

beacon_node/lighthouse_network/src/config.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{Enr, PeerIdSerialized};
55
use directory::{
66
DEFAULT_BEACON_NODE_DIR, DEFAULT_HARDCODED_NETWORK, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR,
77
};
8-
use if_watch::{IpNet, tokio::IfWatcher};
8+
use if_watch::{IpNet, smol::IfWatcher};
99
use libp2p::Multiaddr;
1010
use network_utils::listen_addr::{ListenAddr, ListenAddress};
1111
use serde::{Deserialize, Serialize};
@@ -262,10 +262,21 @@ impl Config {
262262
/// A helper function to check if the local host has a globally routeable IPv6 address. If so,
263263
/// returns true.
264264
pub fn is_ipv6_supported() -> bool {
265-
let Ok(watcher) = IfWatcher::new() else {
265+
let Ok(mut watcher) = IfWatcher::new() else {
266266
return false;
267267
};
268268

269+
// Hack to poll for addresses.
270+
let mut ctx = std::task::Context::from_waker(futures::task::noop_waker_ref());
271+
272+
// Ensure all addresses are added.
273+
loop {
274+
match watcher.poll_if_event(&mut ctx) {
275+
std::task::Poll::Ready(Ok(_)) => continue,
276+
_ => break,
277+
}
278+
}
279+
269280
watcher
270281
.iter()
271282
.any(|addr| matches!(addr, IpNet::V6(ip) if is_global_ipv6(&ip.addr())))

0 commit comments

Comments
 (0)