MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / arbitrary

Method arbitrary

ipld/resolver/src/provider_cache.rs:227–255  ·  view source on GitHub ↗
(g: &mut quickcheck::Gen)

Source from the content-addressed store, hash-verified

225 // Limited number of records from a limited set of peers.
226 impl Arbitrary for TestRecords {
227 fn arbitrary(g: &mut quickcheck::Gen) -> Self {
228 let rc = usize::arbitrary(g) % 20;
229 let pc = 1 + rc / 2;
230
231 let mut ps = Vec::new();
232 let mut rs = Vec::new();
233
234 for _ in 0..pc {
235 let pk = Keypair::generate_ed25519();
236 let peer_id = pk.public().to_peer_id();
237 ps.push(peer_id)
238 }
239
240 for _ in 0..rc {
241 let peer_id = ps[usize::arbitrary(g) % ps.len()];
242 let mut subnet_ids = Vec::new();
243 for _ in 0..usize::arbitrary(g) % 5 {
244 subnet_ids.push(ArbSubnetID::arbitrary(g).0)
245 }
246 let record = ProviderRecord {
247 peer_id,
248 subnet_ids,
249 timestamp: Timestamp::arbitrary(g),
250 };
251 rs.push(record)
252 }
253
254 Self(rs)
255 }
256 }
257
258 type Providers = HashMap<SubnetID, HashSet<PeerId>>;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected