Skip to content

Commit 385be2e

Browse files
authored
Update rand dependencies, and fallout from that. (#1764)
Update rand dependencies. This is 98% changing functions/methods to the new names, but there are two places where the change is a tiny bit more. To address #1763, we now use rand::random_bool(0.25). This should result in no functional difference, if I've used the proper lossy boolean. There were a few places where we picked a random usize, then % by 4096. Instead of that, we do a random_range(0..4096)
1 parent 4c0952c commit 385be2e

File tree

19 files changed

+184
-162
lines changed

19 files changed

+184
-162
lines changed

Cargo.lock

Lines changed: 45 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ progenitor = "0.10.0"
8282
progenitor-client = "0.10.0"
8383
proptest = "1.6.0"
8484
rayon = "1.10.0"
85-
rand = { version = "0.8.5", features = ["min_const_gen", "small_rng"] }
86-
rand_chacha = "0.3.1"
85+
rand = { version = "0.9.1", features = [ "small_rng"] }
86+
rand_chacha = "0.9.0"
8787
reedline = "0.39.0"
8888
rangemap = "1.5.1"
8989
reqwest = { version = "0.12", features = ["default", "blocking", "json", "stream"] }

crutest/src/cli.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ async fn rand_write(
260260
/*
261261
* TODO: Allow the user to specify a seed here.
262262
*/
263-
let mut rng = rand_chacha::ChaCha8Rng::from_entropy();
263+
let mut rng = rand_chacha::ChaCha8Rng::from_os_rng();
264264

265265
/*
266266
* Once we have our IO size, decide where the starting offset should
@@ -269,7 +269,7 @@ async fn rand_write(
269269
*/
270270
let size = 1;
271271
let block_max = di.volume_info.total_blocks() - size + 1;
272-
let block_index = rng.gen_range(0..block_max);
272+
let block_index = rng.random_range(0..block_max);
273273

274274
cli_write(volume, di, block_index, size).await
275275
}
@@ -350,8 +350,7 @@ async fn cli_write_unwritten(
350350
let mut data =
351351
BytesMut::with_capacity(di.volume_info.block_size as usize);
352352
data.extend(
353-
(0..di.volume_info.block_size)
354-
.map(|_| rand::thread_rng().gen::<u8>()),
353+
(0..di.volume_info.block_size).map(|_| rand::random::<u8>()),
355354
);
356355
data
357356
};
@@ -914,10 +913,10 @@ async fn process_cli_command(
914913
}
915914
CliMessage::RandRead => {
916915
if let Some(di) = di_option {
917-
let mut rng = rand_chacha::ChaCha8Rng::from_entropy();
916+
let mut rng = rand_chacha::ChaCha8Rng::from_os_rng();
918917
let size = 1;
919918
let block_max = di.volume_info.total_blocks() - size + 1;
920-
let offset = rng.gen_range(0..block_max);
919+
let offset = rng.random_range(0..block_max);
921920

922921
let res = cli_read(volume, di, offset, size).await;
923922
fw.send(CliMessage::ReadResponse(offset, res)).await

0 commit comments

Comments
 (0)