Retain trusted peer snapshot hashes bugfix (#21077)
When retaining trusted peer snapshot hashes, and the peer's full snapshot hashes match a trusted snapshot hash, but the peer doesn't have incremental snapshot hashes, that's fine; the peer's hashes should be retained, not discarded.
This commit is contained in:
@ -1276,7 +1276,9 @@ mod with_incremental_snapshots {
|
|||||||
.get(&peer_snapshot_hash.snapshot_hash.full)
|
.get(&peer_snapshot_hash.snapshot_hash.full)
|
||||||
.map(|trusted_incremental_hashes| {
|
.map(|trusted_incremental_hashes| {
|
||||||
if peer_snapshot_hash.snapshot_hash.incr.is_none() {
|
if peer_snapshot_hash.snapshot_hash.incr.is_none() {
|
||||||
false
|
// If the peer's full snapshot hashes match, but doesn't have any
|
||||||
|
// incremental snapshots, that's fine; keep 'em!
|
||||||
|
true
|
||||||
} else {
|
} else {
|
||||||
trusted_incremental_hashes
|
trusted_incremental_hashes
|
||||||
.contains(peer_snapshot_hash.snapshot_hash.incr.as_ref().unwrap())
|
.contains(peer_snapshot_hash.snapshot_hash.incr.as_ref().unwrap())
|
||||||
@ -1700,11 +1702,14 @@ mod with_incremental_snapshots {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
let expected = vec![PeerSnapshotHash::new(
|
let expected = vec![
|
||||||
contact_info,
|
PeerSnapshotHash::new(contact_info.clone(), *trusted_full_snapshot_hash, None),
|
||||||
*trusted_full_snapshot_hash,
|
PeerSnapshotHash::new(
|
||||||
Some(*trusted_incremental_snapshot_hash),
|
contact_info,
|
||||||
)];
|
*trusted_full_snapshot_hash,
|
||||||
|
Some(*trusted_incremental_snapshot_hash),
|
||||||
|
),
|
||||||
|
];
|
||||||
let mut actual = peer_snapshot_hashes;
|
let mut actual = peer_snapshot_hashes;
|
||||||
retain_trusted_peer_snapshot_hashes(&trusted_snapshot_hashes, &mut actual);
|
retain_trusted_peer_snapshot_hashes(&trusted_snapshot_hashes, &mut actual);
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
|
Reference in New Issue
Block a user