zebrad/components/sync/status/
mock.rs

1//! Test-only mocking code for [`SyncStatus`].
2
3// This code is currently unused with some feature combinations.
4#![allow(dead_code)]
5
6use crate::components::sync::RecentSyncLengths;
7
8use super::SyncStatus;
9
10// TODO: move these methods to RecentSyncLengths
11impl SyncStatus {
12    /// Feed the given [`RecentSyncLengths`] it order to make the matching
13    /// [`SyncStatus`] report that it's close to the tip.
14    pub(crate) fn sync_close_to_tip(recent_syncs: &mut RecentSyncLengths) {
15        for _ in 0..RecentSyncLengths::MAX_RECENT_LENGTHS {
16            recent_syncs.push_extend_tips_length(1);
17        }
18    }
19
20    /// Feed the given [`RecentSyncLengths`] it order to make the matching
21    /// [`SyncStatus`] report that it's not close to the tip.
22    pub(crate) fn sync_far_from_tip(recent_syncs: &mut RecentSyncLengths) {
23        for _ in 0..RecentSyncLengths::MAX_RECENT_LENGTHS {
24            recent_syncs.push_extend_tips_length(Self::MIN_DIST_FROM_TIP * 10);
25        }
26    }
27}