Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tests): reuse function to remove duplicate code #3219

Merged
merged 1 commit into from
Sep 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions core/tests/behavior/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,6 @@ pub fn init_service<B: Builder>() -> Option<Operator> {
Some(op)
}

pub fn gen_bytes() -> (Vec<u8>, 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<usize>) -> (Vec<u8>, usize) {
let mut rng = thread_rng();

Expand All @@ -116,11 +106,12 @@ pub fn gen_bytes_with_range(range: impl SampleRange<usize>) -> (Vec<u8>, usize)
(content, size)
}

pub fn gen_fixed_bytes(size: usize) -> Vec<u8> {
let mut rng = thread_rng();
pub fn gen_bytes() -> (Vec<u8>, 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<u8> {
let (content, _) = gen_bytes_with_range(size..=size);

content
}
Expand Down
Loading