#[cfg(not(feature = "fuzztarget"))]
mod real_rng {
use rand::{thread_rng,Rng};
- use bitcoin::util::uint::Uint256;
pub fn fill_bytes(data: &mut [u8]) {
let mut rng = thread_rng();
rng.fill_bytes(data);
}
- pub fn rand_uint256() -> Uint256 {
- let mut rng = thread_rng();
- Uint256([rng.gen(), rng.gen(), rng.gen(), rng.gen()])
+ pub fn rand_u832() -> [u8; 32] {
+ let mut res = [0; 32];
+ fill_bytes(&mut res);
+ res
}
pub fn rand_f32() -> f32 {
#[cfg(feature = "fuzztarget")]
mod fuzzy_rng {
- use bitcoin::util::uint::Uint256;
use util::byte_utils;
static mut RNG_ITER: u64 = 0;
data[off..].copy_from_slice(&byte_utils::be64_to_array(rng)[0..rem]);
}
- pub fn rand_uint256() -> Uint256 {
+ pub fn rand_u832() -> [u8; 32] {
let rng = unsafe { RNG_ITER += 1; RNG_ITER - 1 };
- Uint256([rng, rng, rng, rng])
+ let mut res = [0; 32];
+ let data = byte_utils::le64_to_array(rng);
+ res[8*0..8*1].copy_from_slice(&data);
+ res[8*1..8*2].copy_from_slice(&data);
+ res[8*2..8*3].copy_from_slice(&data);
+ res[8*3..8*4].copy_from_slice(&data);
+ res
}
pub fn rand_f32() -> f32 {