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

Method arbitrary

fendermint/storage/src/testing.rs:48–78  ·  view source on GitHub ↗
(g: &mut Gen)

Source from the content-addressed store, hash-verified

46/// high probability that we get/delete what we put earlier.
47impl Arbitrary for TestOpNs {
48 fn arbitrary(g: &mut Gen) -> Self {
49 use TestOpKV::*;
50 use TestOpNs::*;
51 match u8::arbitrary(g) % 100 {
52 i if i < 47 => {
53 let ns = g.choose(&["spam", "eggs"]).unwrap();
54 let k = *g.choose(&["foo", "bar", "baz"]).unwrap();
55 match u8::arbitrary(g) % 10 {
56 i if i < 3 => S2I(ns, Get(k.to_owned())),
57 i if i < 4 => S2I(ns, Iter),
58 i if i < 9 => S2I(ns, Put(k.to_owned(), Arbitrary::arbitrary(g))),
59 _ => S2I(ns, Del(k.to_owned())),
60 }
61 }
62 i if i < 94 => {
63 let ns = g.choose(&["fizz", "buzz"]).unwrap();
64 let k = u8::arbitrary(g) % 3;
65 match u8::arbitrary(g) % 10 {
66 i if i < 3 => I2S(ns, Get(k)),
67 i if i < 4 => I2S(ns, Iter),
68 i if i < 9 => {
69 let sz = u8::arbitrary(g) % 5;
70 let s = (0..sz).map(|_| char::arbitrary(g)).collect();
71 I2S(ns, Put(k, s))
72 }
73 _ => I2S(ns, Del(k)),
74 }
75 }
76 _ => Rollback,
77 }
78 }
79}
80
81impl Arbitrary for TestData {

Callers

nothing calls this directly

Calls 1

collectMethod · 0.80

Tested by

no test coverage detected