iroh/socket/remote_map/remote_state/
path_state.rs

1//! The state kept for each network path to a remote endpoint.
2
3use std::{
4    collections::{HashMap, HashSet, VecDeque},
5    sync::Arc,
6};
7
8use n0_error::e;
9use n0_future::time::Instant;
10use rustc_hash::FxHashMap;
11use tokio::sync::oneshot;
12use tracing::trace;
13
14use super::{Source, TransportAddrInfo, TransportAddrUsage};
15use crate::{address_lookup::AddressLookupFailed, metrics::SocketMetrics, socket::transports};
16
17/// Maximum number of non-relay paths we keep around per endpoint.
18pub(super) const MAX_NON_RELAY_PATHS: usize = 30;
19
20/// Maximum number of inactive non-relay paths we keep around per endpoint.
21///
22/// These are paths that at one point been opened and are now closed.
23pub(super) const MAX_INACTIVE_NON_RELAY_PATHS: usize = 10;
24
25/// Map of all paths that we are aware of for a remote endpoint.
26///
27/// Also stores a list of resolve requests which are triggered once at least one path is known,
28/// or once this struct is notified of a failed Address Lookup run.
29#[derive(Debug)]
30pub(super) struct RemotePathState {
31    /// All possible paths we are aware of.
32    ///
33    /// These paths might be entirely impossible to use, since they are added by Address Lookup
34    /// mechanisms. The are only potentially usable.
35    paths: FxHashMap<transports::Addr, PathState>,
36    /// Pending resolve requests from [`Self::resolve_remote`].
37    pending_resolve_requests: VecDeque<oneshot::Sender<Result<(), AddressLookupFailed>>>,
38    metrics: Arc<SocketMetrics>,
39}
40
41/// Describes the usability of this path, i.e. whether it has ever been opened,
42/// when it was closed, or if it has never been usable.
43#[derive(Debug, Default)]
44pub(super) enum PathStatus {
45    /// This path is open and active.
46    Open,
47    /// This path was once opened, but was abandoned at the given [`Instant`].
48    Inactive(Instant),
49    /// This path was never usable (we attempted holepunching and it didn't work).
50    Unusable,
51    /// We have not yet attempted holepunching, or holepunching is currently in
52    /// progress, so we do not know the usability of this path.
53    #[default]
54    Unknown,
55}
56
57impl RemotePathState {
58    pub(super) fn new(metrics: Arc<SocketMetrics>) -> Self {
59        Self {
60            paths: Default::default(),
61            pending_resolve_requests: Default::default(),
62            metrics,
63        }
64    }
65
66    pub(super) fn to_remote_addrs(&self) -> Vec<TransportAddrInfo> {
67        self.paths
68            .iter()
69            .flat_map(|(addr, state)| {
70                let usage = match state.status {
71                    PathStatus::Open => TransportAddrUsage::Active,
72                    PathStatus::Inactive(_) | PathStatus::Unusable | PathStatus::Unknown => {
73                        TransportAddrUsage::Inactive
74                    }
75                };
76                Some(TransportAddrInfo {
77                    addr: addr.clone().into(),
78                    usage,
79                })
80            })
81            .collect()
82    }
83
84    /// Insert a new address of an open path into our list of paths.
85    ///
86    /// This will emit pending resolve requests and trigger pruning paths.
87    pub(super) fn insert_open_path(&mut self, addr: transports::Addr, source: Source) {
88        match addr {
89            transports::Addr::Ip(_) => self.metrics.transport_ip_paths_added.inc(),
90            transports::Addr::Relay(_, _) => self.metrics.transport_relay_paths_added.inc(),
91            transports::Addr::Custom(_) => self.metrics.transport_custom_paths_added.inc(),
92        };
93        let state = self.paths.entry(addr).or_default();
94        state.status = PathStatus::Open;
95        state.sources.insert(source.clone(), Instant::now());
96        self.emit_pending_resolve_requests(None);
97        self.prune_paths();
98    }
99
100    /// Mark a path as abandoned.
101    ///
102    /// If this path does not exist, it does nothing to the
103    /// `RemotePathState`
104    pub(super) fn abandoned_path(&mut self, addr: &transports::Addr) {
105        if let Some(state) = self.paths.get_mut(addr) {
106            if matches!(state.status, PathStatus::Open) {
107                match addr {
108                    transports::Addr::Ip(_) => self.metrics.transport_ip_paths_removed.inc(),
109                    transports::Addr::Relay(_, _) => {
110                        self.metrics.transport_relay_paths_removed.inc()
111                    }
112                    transports::Addr::Custom(_) => {
113                        self.metrics.transport_custom_paths_removed.inc()
114                    }
115                };
116            }
117            match state.status {
118                PathStatus::Open | PathStatus::Inactive(_) => {
119                    state.status = PathStatus::Inactive(Instant::now());
120                }
121                PathStatus::Unusable | PathStatus::Unknown => {
122                    state.status = PathStatus::Unusable;
123                }
124            }
125        }
126    }
127
128    /// Inserts multiple addresses of unknown status into our list of potential paths.
129    ///
130    /// If this caused the path set to transition from empty to non-empty, any
131    /// pending resolve requests are woken with `Ok(())`. Inserts that add no
132    /// new paths (empty iterator, or only duplicates) are a no-op: waking
133    /// pending requests while the path set is still empty would send a bogus
134    /// `AddressLookupFailed::NoResults` while an address lookup is in flight.
135    pub(super) fn insert_multiple(
136        &mut self,
137        addrs: impl Iterator<Item = transports::Addr>,
138        source: Source,
139    ) {
140        let now = Instant::now();
141        let was_empty = self.paths.is_empty();
142        for addr in addrs {
143            self.paths
144                .entry(addr)
145                .or_default()
146                .sources
147                .insert(source.clone(), now);
148        }
149        trace!("added addressing information");
150        if was_empty && !self.paths.is_empty() {
151            self.emit_pending_resolve_requests(None);
152        }
153        self.prune_paths();
154    }
155
156    /// Sends back on `tx` once a possible path to the remote is known.
157    ///
158    /// If there already is a known path, `Ok(())` is returned immediately. Otherwise an
159    /// address lookup is performed and the result is sent back once that
160    /// completes. [`AddressLookupFailed`] is sent if there are no known paths.
161    pub(super) fn resolve_remote(&mut self, tx: oneshot::Sender<Result<(), AddressLookupFailed>>) {
162        if !self.paths.is_empty() {
163            tx.send(Ok(())).ok();
164        } else {
165            self.pending_resolve_requests.push_back(tx);
166        }
167    }
168
169    /// Returns `true` if there are any queued resolve requests from [`Self::resolve_remote`].
170    pub(super) fn resolve_requests_is_empty(&self) -> bool {
171        self.pending_resolve_requests.is_empty()
172    }
173
174    /// Notifies that a Address Lookup run has finished.
175    ///
176    /// This will emit pending resolve requests.
177    pub(super) fn address_lookup_finished(&mut self, result: Result<(), AddressLookupFailed>) {
178        self.emit_pending_resolve_requests(result.err());
179    }
180
181    /// Returns an iterator over the addresses of all paths.
182    pub(super) fn addrs(&self) -> impl Iterator<Item = &transports::Addr> {
183        self.paths.keys()
184    }
185
186    /// Returns whether this stores any addresses.
187    pub(super) fn is_empty(&self) -> bool {
188        self.paths.is_empty()
189    }
190
191    /// Replies to all pending resolve requests.
192    ///
193    /// This is a no-op if no requests are queued. Replies `Ok` if we have any known paths,
194    /// otherwise with the provided `address_lookup_error` or with [`AddressLookupFailed::NoResults`].
195    fn emit_pending_resolve_requests(&mut self, address_lookup_error: Option<AddressLookupFailed>) {
196        if self.pending_resolve_requests.is_empty() {
197            return;
198        }
199        let result = match (self.paths.is_empty(), address_lookup_error) {
200            (false, _) => Ok(()),
201            (true, Some(err)) => Err(err),
202            (true, None) => Err(e!(AddressLookupFailed::NoResults { errors: Vec::new() })),
203        };
204        for tx in self.pending_resolve_requests.drain(..) {
205            tx.send(result.clone()).ok();
206        }
207    }
208
209    /// Prune paths.
210    ///
211    /// Should be invoked any time we insert a new path.
212    ///
213    /// We currently only prune non-relay paths. For more information on the
214    /// criteria for when and which paths we prune, look at the [`prune_non_relay_paths`] function.
215    pub(super) fn prune_paths(&mut self) {
216        prune_non_relay_paths(&mut self.paths);
217    }
218}
219
220/// The state of a single path to the remote endpoint.
221///
222/// Each path is identified by the destination [`transports::Addr`] and they are stored in
223/// the [`RemotePathState`] map in [`RemoteStateActor`].
224///
225/// [`RemoteStateActor`]: super::RemoteStateActor
226#[derive(Debug, Default)]
227pub(super) struct PathState {
228    /// How we learned about this path, and when.
229    ///
230    /// We keep track of only the latest [`Instant`] for each [`Source`], keeping the size
231    /// of the map of sources down to one entry per type of source.
232    pub(super) sources: HashMap<Source, Instant>,
233    /// The usability status of this path.
234    pub(super) status: PathStatus,
235}
236
237/// Prunes the non-relay paths in the paths HashMap.
238///
239/// Only prunes if the number of non-relay paths is above [`MAX_NON_RELAY_PATHS`].
240///
241/// Keeps paths that are open or of unknown status.
242///
243/// Always prunes paths that have unsuccessfully holepunched.
244///
245/// Keeps [`MAX_INACTIVE_NON_RELAY_PATHS`] of the most recently closed paths
246/// that are not currently being used but have successfully been
247/// holepunched previously.
248///
249/// This all ensures that:
250///
251/// - We do not have unbounded growth of paths.
252/// - If we have many paths for this remote, we prune the paths that cannot hole punch.
253/// - We do not prune holepunched paths that are currently not in use too quickly. For
254///   example, if a large number of untested paths are added at once, we will not
255///   immediately prune all of the unused, but valid, paths at once.
256fn prune_non_relay_paths(paths: &mut FxHashMap<transports::Addr, PathState>) {
257    // if the total number of paths is less than the max, bail early
258    if paths.len() < MAX_NON_RELAY_PATHS {
259        return;
260    }
261
262    let primary_paths: Vec<_> = paths.iter().filter(|(addr, _)| !addr.is_relay()).collect();
263
264    // if the total number of non-relay paths is less than the max, bail early
265    if primary_paths.len() < MAX_NON_RELAY_PATHS {
266        return;
267    }
268
269    // paths that were opened at one point but have previously been closed
270    let mut inactive = Vec::with_capacity(primary_paths.len());
271    // paths where we attempted hole punching but it not successful
272    let mut failed = Vec::with_capacity(primary_paths.len());
273
274    for (addr, state) in primary_paths {
275        match state.status {
276            PathStatus::Inactive(t) => {
277                // paths where holepunching succeeded at one point, but the path was closed.
278                inactive.push((addr.clone(), t));
279            }
280            PathStatus::Unusable => {
281                // paths where holepunching has been attempted and failed.
282                failed.push(addr.clone());
283            }
284            _ => {
285                // ignore paths that are open or the status is unknown
286            }
287        }
288    }
289
290    // All paths are bad, don't prune all of them.
291    //
292    // This implies that `inactive` is empty.
293    if failed.len() == paths.len() {
294        // leave the max number of non-relay paths
295        failed.truncate(paths.len().saturating_sub(MAX_NON_RELAY_PATHS));
296    }
297
298    // sort the potentially prunable from most recently closed to least recently closed
299    inactive.sort_by_key(|b| std::cmp::Reverse(b.1));
300
301    // Prune the "oldest" closed paths.
302    let old_inactive =
303        inactive.split_off(inactive.len().saturating_sub(MAX_INACTIVE_NON_RELAY_PATHS));
304
305    // collect all the paths that should be pruned
306    let must_prune: HashSet<_> = failed
307        .into_iter()
308        .chain(old_inactive.into_iter().map(|(addr, _)| addr))
309        .collect();
310
311    paths.retain(|addr, _| !must_prune.contains(addr));
312}
313
314#[cfg(test)]
315mod tests {
316    use std::{
317        net::{Ipv4Addr, SocketAddrV4},
318        time::Duration,
319    };
320
321    use iroh_base::{RelayUrl, SecretKey};
322    use rand::{RngExt, SeedableRng};
323
324    use super::*;
325
326    fn ip_addr(port: u16) -> transports::Addr {
327        transports::Addr::Ip(SocketAddrV4::new(Ipv4Addr::LOCALHOST, port).into())
328    }
329
330    fn path_state_inactive(closed: Instant) -> PathState {
331        PathState {
332            sources: HashMap::new(),
333            status: PathStatus::Inactive(closed),
334        }
335    }
336
337    fn path_state_unusable() -> PathState {
338        PathState {
339            sources: HashMap::new(),
340            status: PathStatus::Unusable,
341        }
342    }
343
344    #[test]
345    fn test_prune_under_max_paths() {
346        let mut paths = FxHashMap::default();
347        for i in 0..20 {
348            paths.insert(ip_addr(i), PathState::default());
349        }
350
351        prune_non_relay_paths(&mut paths);
352        assert_eq!(
353            20,
354            paths.len(),
355            "should not prune when under MAX_NON_RELAY_PATHS"
356        );
357    }
358
359    #[test]
360    fn test_prune_at_max_paths_no_prunable() {
361        let mut paths = FxHashMap::default();
362        // All paths are active (never abandoned), so none should be pruned
363        for i in 0..MAX_NON_RELAY_PATHS {
364            paths.insert(ip_addr(i as u16), PathState::default());
365        }
366
367        prune_non_relay_paths(&mut paths);
368        assert_eq!(
369            MAX_NON_RELAY_PATHS,
370            paths.len(),
371            "should not prune active paths"
372        );
373    }
374
375    #[test]
376    fn test_prune_failed_holepunch() {
377        let mut paths = FxHashMap::default();
378
379        // Add 20 active paths
380        for i in 0..20 {
381            paths.insert(ip_addr(i), PathState::default());
382        }
383
384        // Add 15 failed holepunch paths (must_prune)
385        for i in 20..35 {
386            paths.insert(ip_addr(i), path_state_unusable());
387        }
388
389        prune_non_relay_paths(&mut paths);
390
391        // All failed holepunch paths should be pruned
392        assert_eq!(20, paths.len());
393        for i in 0..20 {
394            assert!(paths.contains_key(&ip_addr(i)));
395        }
396        for i in 20..35 {
397            assert!(!paths.contains_key(&ip_addr(i)));
398        }
399    }
400
401    #[test]
402    fn test_prune_keeps_most_recent_inactive() {
403        let mut paths = FxHashMap::default();
404        let now = Instant::now();
405
406        // Add 15 active paths
407        for i in 0..15 {
408            paths.insert(ip_addr(i), PathState::default());
409        }
410
411        // Add 20 inactive paths with different abandon times
412        // Ports 15-34, with port 34 being most recently abandoned
413        for i in 0..20 {
414            let abandoned_time = now - Duration::from_secs((20 - i) as u64);
415            paths.insert(ip_addr(15 + i as u16), path_state_inactive(abandoned_time));
416        }
417
418        assert_eq!(35, paths.len());
419        prune_non_relay_paths(&mut paths);
420
421        // Should keep 15 active + 10 most recently abandoned
422        assert_eq!(25, paths.len());
423
424        // Active paths should remain
425        for i in 0..15 {
426            assert!(paths.contains_key(&ip_addr(i)));
427        }
428
429        // Most recently abandoned (ports 25-34) should remain
430        for i in 25..35 {
431            assert!(paths.contains_key(&ip_addr(i)), "port {} should be kept", i);
432        }
433
434        // Oldest abandoned (ports 15-24) should be pruned
435        for i in 15..25 {
436            assert!(
437                !paths.contains_key(&ip_addr(i)),
438                "port {} should be pruned",
439                i
440            );
441        }
442    }
443
444    #[test]
445    fn test_prune_mixed_must_and_can_prune() {
446        let mut paths = FxHashMap::default();
447        let now = Instant::now();
448
449        // Add 15 active paths
450        for i in 0..15 {
451            paths.insert(ip_addr(i), PathState::default());
452        }
453
454        // Add 5 failed holepunch paths
455        for i in 15..20 {
456            paths.insert(ip_addr(i), path_state_unusable());
457        }
458
459        // Add 15 usable but abandoned paths
460        for i in 0..15 {
461            let abandoned_time = now - Duration::from_secs((15 - i) as u64);
462            paths.insert(ip_addr(20 + i as u16), path_state_inactive(abandoned_time));
463        }
464
465        assert_eq!(35, paths.len());
466        prune_non_relay_paths(&mut paths);
467
468        // Remove all failed paths -> down to 30
469        // Keep MAX_INACTIVE_NON_RELAY_PATHS, eg remove 5 usable but abandoned paths -> down to 20
470        assert_eq!(20, paths.len());
471
472        // Active paths should remain
473        for i in 0..15 {
474            assert!(paths.contains_key(&ip_addr(i)));
475        }
476
477        // Failed holepunch should be pruned
478        for i in 15..20 {
479            assert!(!paths.contains_key(&ip_addr(i)));
480        }
481
482        // Most recently abandoned (ports 30-34) should remain
483        for i in 30..35 {
484            assert!(paths.contains_key(&ip_addr(i)), "port {} should be kept", i);
485        }
486    }
487
488    #[test]
489    fn test_prune_relay_paths_not_counted() {
490        let mut paths = FxHashMap::default();
491
492        // Add 25 IP paths (under MAX_NON_RELAY_PATHS)
493        for i in 0..25 {
494            paths.insert(ip_addr(i), path_state_unusable());
495        }
496
497        let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(0u64);
498        let relay_url: RelayUrl = url::Url::parse("https://localhost")
499            .expect("should be valid url")
500            .into();
501        // Add 10 relay addresses
502        for _ in 0..10 {
503            let id = SecretKey::from_bytes(&rng.random()).public();
504            let relay_addr = transports::Addr::Relay(relay_url.clone(), id);
505            paths.insert(relay_addr, PathState::default());
506        }
507
508        assert_eq!(35, paths.len()); // 25 IP + 10 relay
509        prune_non_relay_paths(&mut paths);
510
511        // Should not prune since non-relay paths < MAX_NON_RELAY_PATHS
512        assert_eq!(35, paths.len());
513    }
514
515    #[test]
516    fn test_prune_preserves_never_dialed() {
517        let mut paths = FxHashMap::default();
518
519        // Add 20 never-dialed paths (PathStatus::Unknown)
520        for i in 0..20 {
521            paths.insert(ip_addr(i), PathState::default());
522        }
523
524        // Add 15 failed paths to trigger pruning
525        for i in 20..35 {
526            paths.insert(ip_addr(i), path_state_unusable());
527        }
528
529        prune_non_relay_paths(&mut paths);
530
531        // Never-dialed paths should be preserved
532        for i in 0..20 {
533            assert!(paths.contains_key(&ip_addr(i)));
534        }
535    }
536
537    #[test]
538    fn test_prune_all_paths_failed() {
539        let mut paths = FxHashMap::default();
540
541        // Add 40 failed holepunch paths (all paths have failed)
542        for i in 0..40 {
543            paths.insert(ip_addr(i), path_state_unusable());
544        }
545
546        assert_eq!(40, paths.len());
547        prune_non_relay_paths(&mut paths);
548
549        // Should keep MAX_NON_RELAY_PATHS instead of pruning everything
550        // This prevents catastrophic loss of all path information
551        assert_eq!(
552            MAX_NON_RELAY_PATHS,
553            paths.len(),
554            "should keep MAX_NON_RELAY_PATHS when all paths failed"
555        );
556    }
557
558    #[test]
559    fn test_insert_open_path() {
560        let mut state = RemotePathState::new(Default::default());
561        let addr = ip_addr(1000);
562        let source = Source::Connection;
563
564        assert!(state.is_empty());
565
566        state.insert_open_path(addr.clone(), source.clone());
567
568        assert!(!state.is_empty());
569        assert!(state.paths.contains_key(&addr));
570        let path = &state.paths[&addr];
571        assert!(matches!(path.status, PathStatus::Open));
572        assert_eq!(path.sources.len(), 1);
573        assert!(path.sources.contains_key(&source));
574    }
575
576    #[test]
577    fn test_abandoned_path() {
578        let metrics = Arc::new(SocketMetrics::default());
579        let mut state = RemotePathState::new(metrics.clone());
580
581        // Test: Open goes to Inactive
582        let addr_open = ip_addr(1000);
583        state.insert_open_path(addr_open.clone(), Source::Connection);
584        assert!(matches!(state.paths[&addr_open].status, PathStatus::Open));
585        assert_eq!(metrics.transport_ip_paths_added.get(), 1);
586
587        state.abandoned_path(&addr_open);
588        assert!(matches!(
589            state.paths[&addr_open].status,
590            PathStatus::Inactive(_)
591        ));
592        assert_eq!(metrics.transport_ip_paths_added.get(), 1);
593        assert_eq!(metrics.transport_ip_paths_removed.get(), 1);
594
595        // Test: Inactive stays Inactive
596        state.abandoned_path(&addr_open);
597        assert!(matches!(
598            state.paths[&addr_open].status,
599            PathStatus::Inactive(_)
600        ));
601        assert_eq!(metrics.transport_ip_paths_added.get(), 1);
602        assert_eq!(metrics.transport_ip_paths_removed.get(), 1);
603
604        // Test: Unknown goes to Unusable
605        let addr_unknown = ip_addr(2000);
606        state.insert_multiple([addr_unknown.clone()].into_iter(), Source::Connection);
607        assert!(matches!(
608            state.paths[&addr_unknown].status,
609            PathStatus::Unknown
610        ));
611        assert_eq!(metrics.transport_ip_paths_added.get(), 1);
612        assert_eq!(metrics.transport_ip_paths_removed.get(), 1);
613
614        state.abandoned_path(&addr_unknown);
615        assert!(matches!(
616            state.paths[&addr_unknown].status,
617            PathStatus::Unusable
618        ));
619        assert_eq!(metrics.transport_ip_paths_added.get(), 1);
620        assert_eq!(metrics.transport_ip_paths_removed.get(), 1);
621
622        // Test: Unusable stays Unusable
623        state.abandoned_path(&addr_unknown);
624        assert!(matches!(
625            state.paths[&addr_unknown].status,
626            PathStatus::Unusable
627        ));
628        assert_eq!(metrics.transport_ip_paths_added.get(), 1);
629        assert_eq!(metrics.transport_ip_paths_removed.get(), 1);
630
631        // Test: Unusable can go to open
632        state.insert_open_path(addr_unknown.clone(), Source::Connection);
633        assert!(matches!(
634            state.paths[&addr_unknown].status,
635            PathStatus::Open
636        ));
637        assert_eq!(metrics.transport_ip_paths_added.get(), 2);
638        assert_eq!(metrics.transport_ip_paths_removed.get(), 1);
639    }
640
641    /// An empty `insert_multiple` must not drain pending resolve requests.
642    ///
643    /// This reproduces the race where multiple concurrent `connect_with_opts`
644    /// calls send `ResolveRemote` messages with empty addrs. The first pushes
645    /// a tx, then the second's `insert_multiple([])` used to drain that tx
646    /// with `NoResults { errors: [] }`, even though an address lookup was
647    /// still in flight and would shortly have resolved it.
648    #[test]
649    fn empty_insert_does_not_drain_pending() {
650        let metrics = Arc::new(SocketMetrics::default());
651        let mut state = RemotePathState::new(metrics);
652
653        let (tx, mut rx) = oneshot::channel();
654        state.resolve_remote(tx);
655
656        // Second concurrent resolve arrives with empty addrs (no app-provided
657        // addresses) while address lookup is still running.
658        state.insert_multiple(std::iter::empty(), Source::App);
659
660        assert!(
661            rx.try_recv().is_err(),
662            "pending tx must stay pending while paths are empty and lookup is in flight"
663        );
664
665        // When real addresses arrive, the tx resolves Ok.
666        state.insert_multiple([ip_addr(4242)].into_iter(), Source::App);
667        let resolved = rx.try_recv().expect("tx should have been woken");
668        assert!(resolved.is_ok(), "expected Ok once a path was added");
669    }
670
671    /// `address_lookup_finished(Ok(()))` drains pending requests with `NoResults` when no paths are known.
672    ///
673    /// This is the "lookup done but nothing was found" signal and it must
674    /// still reach callers.
675    #[test]
676    fn address_lookup_finished_empty_emits_no_results() {
677        let metrics = Arc::new(SocketMetrics::default());
678        let mut state = RemotePathState::new(metrics);
679
680        let (tx, mut rx) = oneshot::channel();
681        state.resolve_remote(tx);
682
683        state.address_lookup_finished(Ok(()));
684
685        let resolved = rx.try_recv().expect("tx should have been woken");
686        assert!(matches!(
687            resolved,
688            Err(AddressLookupFailed::NoResults { .. })
689        ));
690    }
691}