MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / check_providers

Function check_providers

ipld/resolver/src/provider_cache.rs:293–311  ·  view source on GitHub ↗

Check the cache against the reference built in the test.

(providers: &Providers, cache: &SubnetProviderCache)

Source from the content-addressed store, hash-verified

291
292 /// Check the cache against the reference built in the test.
293 fn check_providers(providers: &Providers, cache: &SubnetProviderCache) -> Result<(), String> {
294 for (subnet_id, exp_peer_ids) in providers {
295 let peer_ids = cache.providers_of_subnet(subnet_id);
296 if peer_ids.len() != exp_peer_ids.len() {
297 return Err(format!(
298 "expected {} peers, got {} in subnet {:?}",
299 exp_peer_ids.len(),
300 peer_ids.len(),
301 subnet_id
302 ));
303 }
304 for peer_id in peer_ids {
305 if !exp_peer_ids.contains(&peer_id) {
306 return Err("wrong peer ID".into());
307 }
308 }
309 }
310 Ok(())
311 }
312
313 #[quickcheck]
314 fn prop_subnets_pruned(records: TestRecords, max_subnets: usize) -> bool {

Callers 2

prop_providers_listedFunction · 0.85
prop_providers_prunedFunction · 0.85

Calls 4

providers_of_subnetMethod · 0.45
lenMethod · 0.45
containsMethod · 0.45
intoMethod · 0.45

Tested by

no test coverage detected