Skip to content

Commit

Permalink
fix: Fix test that for some reason assumes sort order in a vec
Browse files Browse the repository at this point in the history
  • Loading branch information
rklaehn committed Oct 21, 2022
1 parent 93546b1 commit d57b12a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions iroh-resolver/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ impl Block {
return Err(InvalidMultihash(mh.to_bytes()).into());
}
// check that the links are complete
let links = parse_links(&self.cid, &self.data)?;
anyhow::ensure!(links == self.links, "links do not match");
let expected_links = parse_links(&self.cid, &self.data)?;
let mut actual_links = self.links.clone();
actual_links.sort();
// TODO: why do the actual links need to be deduplicated?
actual_links.dedup();
anyhow::ensure!(expected_links == actual_links, "links do not match");
Ok(())
}

Expand Down Expand Up @@ -1398,6 +1402,8 @@ impl<T: ContentLoader> Resolver<T> {
}

/// Extract links from the given content.
///
/// Links will be returned as a sorted vec
pub fn parse_links(cid: &Cid, bytes: &[u8]) -> Result<Vec<Cid>> {
let codec = Codec::try_from(cid.codec()).context("unknown codec")?;
let mut cids = BTreeSet::new();
Expand Down

0 comments on commit d57b12a

Please sign in to comment.