diff --git a/core/tests/behavior/utils.rs b/core/tests/behavior/utils.rs index c9c9a24e39f8..7cdd032a1b80 100644 --- a/core/tests/behavior/utils.rs +++ b/core/tests/behavior/utils.rs @@ -96,16 +96,6 @@ pub fn init_service() -> Option { Some(op) } -pub fn gen_bytes() -> (Vec, usize) { - let mut rng = thread_rng(); - - let size = rng.gen_range(1..4 * 1024 * 1024); - let mut content = vec![0; size]; - rng.fill_bytes(&mut content); - - (content, size) -} - pub fn gen_bytes_with_range(range: impl SampleRange) -> (Vec, usize) { let mut rng = thread_rng(); @@ -116,11 +106,12 @@ pub fn gen_bytes_with_range(range: impl SampleRange) -> (Vec, usize) (content, size) } -pub fn gen_fixed_bytes(size: usize) -> Vec { - let mut rng = thread_rng(); +pub fn gen_bytes() -> (Vec, usize) { + gen_bytes_with_range(1..4 * 1024 * 1024) +} - let mut content = vec![0; size]; - rng.fill_bytes(&mut content); +pub fn gen_fixed_bytes(size: usize) -> Vec { + let (content, _) = gen_bytes_with_range(size..=size); content }