Skip to content

Commit

Permalink
test(network): check the exact number of inventory peers
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Feb 7, 2022
1 parent 4e3d3b5 commit cb561d3
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ async fn inv_registry_one_advertised_ok() {
inv_registry.advertising_peers(test_hash).next(),
Some(&test_peer),
);
assert_eq!(inv_registry.advertising_peers(test_hash).count(), 1);
assert_eq!(inv_registry.missing_peers(test_hash).count(), 0);
}

Expand Down Expand Up @@ -87,6 +88,7 @@ async fn inv_registry_one_missing_ok() {
inv_registry.missing_peers(test_hash).next(),
Some(&test_peer),
);
assert_eq!(inv_registry.missing_peers(test_hash).count(), 1);
}

/// Check inventory registration for one hash/peer prefers missing over advertised.
Expand Down Expand Up @@ -131,6 +133,7 @@ async fn inv_registry_prefer_missing_order(missing_first: bool) {
inv_registry.missing_peers(test_hash).next(),
Some(&test_peer),
);
assert_eq!(inv_registry.missing_peers(test_hash).count(), 1);
}

/// Check inventory registration for one hash/peer prefers current over previous.
Expand Down Expand Up @@ -179,11 +182,13 @@ async fn inv_registry_prefer_current_order(missing_current: bool) {
inv_registry.missing_peers(test_hash).next(),
Some(&test_peer),
);
assert_eq!(inv_registry.missing_peers(test_hash).count(), 1);
} else {
assert_eq!(
inv_registry.advertising_peers(test_hash).next(),
Some(&test_peer),
);
assert_eq!(inv_registry.advertising_peers(test_hash).count(), 1);
assert_eq!(inv_registry.missing_peers(test_hash).count(), 0);
}
}
Expand Down

0 comments on commit cb561d3

Please sign in to comment.