Skip to content

Commit 92adec1

Browse files
committed
test: Upgrade rand and proptest
1 parent 575964f commit 92adec1

4 files changed

Lines changed: 17 additions & 17 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ default = ["std"]
2121
std = []
2222

2323
[dev-dependencies]
24-
rand = "0.8"
25-
proptest = "1.4"
24+
rand = "0.9"
25+
proptest = "1.7"
2626
bitcoin = "0.32"

tests/bnb.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use proptest::{prelude::*, proptest, test_runner::*};
1010

1111
fn test_wv(mut rng: impl RngCore) -> impl Iterator<Item = Candidate> {
1212
core::iter::repeat_with(move || {
13-
let value = rng.gen_range(0..1_000);
13+
let value = rng.random_range(0..1_000);
1414
let mut candidate = Candidate {
1515
value,
1616
weight: 100,
17-
input_count: rng.gen_range(1..2),
18-
is_segwit: rng.gen_bool(0.5),
17+
input_count: rng.random_range(1..2),
18+
is_segwit: rng.random_bool(0.5),
1919
};
2020
// HACK: set is_segwit = true for all these tests because you can't actually lower bound
2121
// things easily with how segwit inputs interfere with their weights. We can't modify the
@@ -100,7 +100,7 @@ fn bnb_finds_an_exact_solution_in_n_iter() {
100100
.last()
101101
.expect("it found a solution");
102102

103-
assert_eq!(rounds, 3150);
103+
assert_eq!(rounds, 3194);
104104
assert_eq!(best.input_weight(), solution_weight);
105105
assert_eq!(best.selected_value(), target_value, "score={:?}", score);
106106
}
@@ -134,9 +134,9 @@ fn bnb_finds_solution_if_possible_in_n_iter() {
134134
.last()
135135
.expect("found a solution");
136136

137-
assert_eq!(rounds, 193);
137+
assert_eq!(rounds, 164);
138138
let excess = sol.excess(target, Drain::NONE);
139-
assert_eq!(excess, 1);
139+
assert_eq!(excess, 0);
140140
}
141141

142142
proptest! {

tests/changeless.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use rand::{prelude::IteratorRandom, Rng, RngCore};
1111

1212
fn test_wv(mut rng: impl RngCore) -> impl Iterator<Item = Candidate> {
1313
core::iter::repeat_with(move || {
14-
let value = rng.gen_range(0..1_000);
14+
let value = rng.random_range(0..1_000);
1515
Candidate {
1616
value,
17-
weight: rng.gen_range(0..100),
18-
input_count: rng.gen_range(1..2),
17+
weight: rng.random_range(0..100),
18+
input_count: rng.random_range(1..2),
1919
is_segwit: false,
2020
}
2121
})

tests/common.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ impl StrategyParams {
243243
pub fn gen_candidates(n: usize) -> Vec<Candidate> {
244244
let mut rng = TestRng::deterministic_rng(RngAlgorithm::ChaCha);
245245
core::iter::repeat_with(move || {
246-
let value = rng.gen_range(1..500_001);
247-
let weight = rng.gen_range(1..2001);
248-
let input_count = rng.gen_range(1..3);
249-
let is_segwit = rng.gen_bool(0.01);
246+
let value = rng.random_range(1..500_001);
247+
let weight = rng.random_range(1..2001);
248+
let input_count = rng.random_range(1..3);
249+
let is_segwit = rng.random_bool(0.01);
250250

251251
Candidate {
252252
value,
@@ -465,11 +465,11 @@ pub fn compare_against_benchmarks<M: BnbMetric + Clone>(
465465
}
466466

467467
#[allow(unused)]
468-
fn randomly_satisfy_target<'a>(
468+
fn randomly_satisfy_target<'a, R: rand::Rng>(
469469
cs: &CoinSelector<'a>,
470470
target: Target,
471471
change_policy: ChangePolicy,
472-
rng: &mut impl RngCore,
472+
rng: &mut R,
473473
mut metric: impl BnbMetric,
474474
) -> CoinSelector<'a> {
475475
let mut cs = cs.clone();

0 commit comments

Comments
 (0)