pub struct TestRng { /* private fields */ }Expand description
A fast RNG used solely for testing and benchmarking, not for any real world purposes.
Implementations§
Source§impl TestRng
impl TestRng
pub fn fixed(seed: u64) -> TestRng
pub fn from_seed(seed: u64) -> TestRng
Sourcepub fn next_string(&mut self, max_bytes: u32, is_fixed_size: bool) -> String
pub fn next_string(&mut self, max_bytes: u32, is_fixed_size: bool) -> String
Returns a randomly-sampled String, given the maximum size in bytes and an RNG.
Some of the snarkVM internal tests involve the random generation of strings, which are parsed and tested against the original ones. However, since the string parser rejects certain characters, if those characters are randomly generated, the tests fail.
To prevent these failures, as we randomly generate the characters, we ensure that they are not among the ones rejected by the parser; if they are, we adjust them to be allowed characters.
Note that the randomness of the characters is strictly for testing purposes; also note that the disallowed characters are a small fraction of the total set of characters, and thus the adjustments rarely occur.
Trait Implementations§
Source§impl TryRng for TestRng
impl TryRng for TestRng
impl TryCryptoRng for TestRng
Auto Trait Implementations§
impl Freeze for TestRng
impl RefUnwindSafe for TestRng
impl Send for TestRng
impl Sync for TestRng
impl Unpin for TestRng
impl UnsafeUnpin for TestRng
impl UnwindSafe for TestRng
Blanket Implementations§
Source§impl<R> TryRngCore for Rwhere
R: TryRng,
impl<R> TryRngCore for Rwhere
R: TryRng,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R> RngExt for R
impl<R> RngExt for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. Read more