This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs-object-store.git


The following commit(s) were added to refs/heads/main by this push:
     new 00e0df5  Remove use of deprecated StepRng from tests (#449)
00e0df5 is described below

commit 00e0df5d3f13c26756de31f5ab5962fbc39cbd14
Author: Raphael Taylor-Davies <[email protected]>
AuthorDate: Mon Jul 28 14:45:26 2025 +0100

    Remove use of deprecated StepRng from tests (#449)
---
 src/client/backoff.rs | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/client/backoff.rs b/src/client/backoff.rs
index 8193e8b..e1160d6 100644
--- a/src/client/backoff.rs
+++ b/src/client/backoff.rs
@@ -110,7 +110,23 @@ impl Backoff {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use rand::rngs::mock::StepRng;
+    use rand::rand_core::impls::fill_bytes_via_next;
+
+    struct FixedRng(u64);
+
+    impl RngCore for FixedRng {
+        fn next_u32(&mut self) -> u32 {
+            self.0 as _
+        }
+
+        fn next_u64(&mut self) -> u64 {
+            self.0
+        }
+
+        fn fill_bytes(&mut self, dst: &mut [u8]) {
+            fill_bytes_via_next(self, dst)
+        }
+    }
 
     #[test]
     fn test_backoff() {
@@ -127,7 +143,7 @@ mod tests {
         let assert_fuzzy_eq = |a: f64, b: f64| assert!((b - a).abs() < 0.0001, 
"{a} != {b}");
 
         // Create a static rng that takes the minimum of the range
-        let rng = Box::new(StepRng::new(0, 0));
+        let rng = Box::new(FixedRng(0));
         let mut backoff = Backoff::new_with_rng(&config, Some(rng));
 
         for _ in 0..20 {
@@ -135,7 +151,7 @@ mod tests {
         }
 
         // Create a static rng that takes the maximum of the range
-        let rng = Box::new(StepRng::new(u64::MAX, 0));
+        let rng = Box::new(FixedRng(u64::MAX));
         let mut backoff = Backoff::new_with_rng(&config, Some(rng));
 
         for i in 0..20 {
@@ -144,7 +160,7 @@ mod tests {
         }
 
         // Create a static rng that takes the mid point of the range
-        let rng = Box::new(StepRng::new(u64::MAX / 2, 0));
+        let rng = Box::new(FixedRng(u64::MAX / 2));
         let mut backoff = Backoff::new_with_rng(&config, Some(rng));
 
         let mut value = init_backoff_secs;

Reply via email to