1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! Mock [`AddressBookPeers`] for use in tests.

use crate::{meta_addr::MetaAddr, AddressBookPeers};

/// A mock [`AddressBookPeers`] implementation that's always empty.
#[derive(Default, Clone)]
pub struct MockAddressBookPeers {
    /// Return value for mock `recently_live_peers` method.
    recently_live_peers: Vec<MetaAddr>,
}

impl MockAddressBookPeers {
    /// Creates a new [`MockAddressBookPeers`]
    pub fn new(recently_live_peers: Vec<MetaAddr>) -> Self {
        Self {
            recently_live_peers,
        }
    }
}

impl AddressBookPeers for MockAddressBookPeers {
    fn recently_live_peers(&self, _now: chrono::DateTime<chrono::Utc>) -> Vec<MetaAddr> {
        self.recently_live_peers.clone()
    }
}