radicle: Announcer test adapting the replication target

The replication target should be constrained to the number of nodes to sync
with, if the original value exceeds that number.
This commit is contained in:
Fintan Halpenny 2025-08-06 11:51:40 +01:00 committed by Lorenz Leutgeb
parent 685c84e598
commit ca7231e652
1 changed files with 22 additions and 1 deletions

View File

@ -579,7 +579,8 @@ mod test {
let config = AnnouncerConfig::public(
local,
ReplicationFactor::must_reach(5), // High target that we won't reach with preferred alone
// High target that we won't reach with preferred alone
ReplicationFactor::must_reach(5),
preferred_seeds.clone(),
BTreeSet::new(),
unsynced,
@ -929,6 +930,26 @@ mod test {
}
}
#[test]
fn announcer_adapts_target_to_reach() {
let local = arbitrary::gen::<NodeId>(0);
// Only 3 nodes available
let unsynced = arbitrary::set::<NodeId>(3..=3)
.into_iter()
.collect::<BTreeSet<_>>();
let config = AnnouncerConfig::public(
local,
ReplicationFactor::must_reach(5), // Want 5 but only have 3
BTreeSet::new(),
BTreeSet::new(),
unsynced.clone(),
);
let announcer = Announcer::new(config).unwrap();
assert_eq!(announcer.target().replicas().lower_bound(), 3);
}
#[test]
fn announcer_with_replication_factor_zero_and_preferred_seeds() {
let local = arbitrary::gen::<NodeId>(0);