Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
fix: resolve failing tests after SectionAuthProvider refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed May 3, 2021
1 parent 67021d8 commit aedf370
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/routing/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,10 @@ async fn handle_agreement_on_offline_of_elder() -> Result<()> {
.filter(|peer| *peer != remove_peer)
.chain(iter::once(existing_peer))
.collect();

println!("actual_section_auth.peers() {:?}", actual_section_auth);
println!("expected_new_elders {:?}", expected_new_elders);

itertools::assert_equal(actual_section_auth.peers(), expected_new_elders.clone());

let expected_dkg_start_recipients: Vec<_> = expected_new_elders
Expand All @@ -780,6 +784,8 @@ async fn handle_agreement_on_offline_of_elder() -> Result<()> {
.map(Peer::addr)
.copied()
.collect();
println!("recipients {:?}", recipients);
println!("expected_dkg_start_recipients {:?}", expected_dkg_start_recipients);
assert_eq!(recipients, expected_dkg_start_recipients);

dkg_start_sent = true;
Expand Down
11 changes: 8 additions & 3 deletions src/section/section_authority_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ impl SectionAuthorityProvider {
pub(crate) fn peers(
&'_ self,
) -> impl Iterator<Item = Peer> + DoubleEndedIterator + ExactSizeIterator + Clone + '_ {
self.elders
.iter()
.map(|(name, addr)| Peer::new(*name, *addr))
// The `reachable` flag of Peer is defaulted to `false` during the construction.
// As the SectionAuthorityProvider only holds the list of alive elders, it shall be safe
// to set the flag as true here during the mapping.
self.elders.iter().map(|(name, addr)| {
let mut peer = Peer::new(*name, *addr);
peer.set_reachable(true);
peer
})
}

/// Returns the index of the elder with `name` in this set of elders.
Expand Down

0 comments on commit aedf370

Please sign in to comment.