Issues to combine `Arbitrary` and `ForcedRng`
shaobo-he-aws opened this issue · 0 comments
It seems there will be a lot of wasted cycles when we use ArbitraryGenerator
and ForcedRng
. IIUC, ForcedRng
will be called again if the generation function returns a None
, which seems to me is under the assumption that generation failures result from insufficient random bytes. This assumption may not hold for users of the Arbitrary
crate. For example, if we want to generate values under certain constraints using the arbitrary
trait method, one strategy is to generate a weaker value and return an Err
if that value doesn't satisfy the constraints. The rationale is that the fuzzer should keep the values satisfying the constraints as they lead to deeper code coverage. In other words, we save the trouble of generating values guaranteed to satisfy the constraints. So, let's say we adopt the strategy and then ForcedRng
's generate_from_bytes
method will be called again and again until the number of bytes generated is above the upper bound specified by the argument, which could be unbounded.