Skip to content

Commit 8ec7019

Browse files
committed
fix failed tests
1 parent abc48f7 commit 8ec7019

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

crates/cfxcore/core/src/channel.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ mod tests {
256256

257257
// create async sender
258258
let fut3 = async move {
259-
let mut rng = rand::thread_rng();
259+
let mut rng = rand::rng();
260260
let mut sent = vec![];
261-
for t in (0..100).map(|_| rng.gen()) {
261+
for t in (0..100).map(|_| rng.random()) {
262262
chan.send(t);
263263
sent.push(t);
264264
}
@@ -285,9 +285,9 @@ mod tests {
285285

286286
// create async sender
287287
let fut_a = async move {
288-
let mut rng = rand::thread_rng();
288+
let mut rng = rand::rng();
289289

290-
for t in (0..100).map(|_| rng.gen()) {
290+
for t in (0..100).map(|_| rng.random()) {
291291
send_a.send(t);
292292
let t2 = rec_a.recv().await;
293293

crates/cfxcore/core/src/consensus/pivot_hint/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rand::{thread_rng, RngCore};
1+
use rand::{rng, RngCore};
22
use std::{
33
fs::File,
44
io::{Read, Seek, SeekFrom},
@@ -53,7 +53,7 @@ fn test_pivot_hint() {
5353
let pivot_hint = make_test_pivot_hint();
5454
let mut test_file = TestHashFile::new();
5555

56-
let mut rng = thread_rng();
56+
let mut rng = rng();
5757
for _ in 0..100_000 {
5858
let fork_at = rng.next_u64() % 1_500_000;
5959
if fork_at == 0 {

crates/cfxcore/core/src/light_protocol/handler/sync/headers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ mod tests {
459459
headers.push(h5.clone());
460460
headers.push(h6.clone());
461461

462-
headers.shuffle(&mut rand::thread_rng());
462+
headers.shuffle(&mut rand::rng());
463463
let mut queue = PriorityQueue::new();
464464
queue.extend(headers);
465465

crates/util/treap-map/benches/map_cmp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn make_seperate_map(
4141
for _ in 0..SIZE {
4242
let key = rng.random_range(0..SIZE * 2);
4343
btree_map.insert(key, key);
44-
treap_map.insert(key, (), rng.gen::<u64>() % u32::MAX as u64);
44+
treap_map.insert(key, (), rng.random::<u64>() % u32::MAX as u64);
4545
}
4646
(treap_map, btree_map)
4747
}

crates/util/treap-map/benches/useless_weight.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn make_small_weight_map(mut rng: impl Rng) -> TreapMap<SmallWeight> {
3434
let mut treap_map = TreapMap::<SmallWeight>::new();
3535
for _ in 0..SIZE {
3636
let key = rng.random_range(0..(SIZE * 2));
37-
treap_map.insert(key, key, rng.gen::<u64>() >> 14);
37+
treap_map.insert(key, key, rng.random::<u64>() >> 14);
3838
}
3939
treap_map
4040
}
@@ -43,7 +43,7 @@ fn make_large_weight_map(mut rng: impl Rng) -> TreapMap<LargeWeight> {
4343
let mut treap_map = TreapMap::<LargeWeight>::new();
4444
for _ in 0..SIZE {
4545
let key = rng.random_range(0..(SIZE * 2));
46-
treap_map.insert(key, key, U512(rng.gen::<[u64; 8]>()) >> 14);
46+
treap_map.insert(key, key, U512(rng.random::<[u64; 8]>()) >> 14);
4747
}
4848
treap_map
4949
}

crates/util/treap-map/src/tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use primitives::{
1111
transaction::native_transaction::NativeTransaction, Action,
1212
SignedTransaction, Transaction,
1313
};
14-
use rand::{seq::SliceRandom, thread_rng, Rng, RngCore, SeedableRng};
14+
use rand::{rng, seq::SliceRandom, Rng, RngCore, SeedableRng};
1515
use rand_chacha::ChaChaRng;
1616
use rand_xorshift::XorShiftRng;
1717
use std::{
@@ -198,7 +198,7 @@ fn test_insert_query_random() {
198198
let mut tx_vec: Vec<SignedTransaction> = vec![];
199199

200200
for _ in 0..operation_num {
201-
let operation = match operation_rng.gen::<u32>() % 4 {
201+
let operation = match operation_rng.random::<u32>() % 4 {
202202
0 => Operation::Len,
203203
1 => Operation::ContainsKey,
204204
2 => Operation::Insert,
@@ -267,7 +267,7 @@ fn test_insert_remove_query_random() {
267267
let mut tx_vec: Vec<SignedTransaction> = vec![];
268268

269269
for _ in 0..operation_num {
270-
let operation = match operation_rng.gen::<u32>() % 7 {
270+
let operation = match operation_rng.random::<u32>() % 7 {
271271
0 => Operation::Len,
272272
1 => Operation::ContainsKey,
273273
2..=3 => Operation::Insert,
@@ -391,7 +391,7 @@ fn test_apply_op_change_value() {
391391
}
392392
// Test update value
393393
let mut indicies: Vec<_> = (0u32..200).collect();
394-
indicies.shuffle(&mut thread_rng());
394+
indicies.shuffle(&mut rng());
395395
for i in indicies {
396396
let should_fail = i % 3 == 0;
397397
let update = |node: &mut Node<_>| {
@@ -439,7 +439,7 @@ fn test_apply_op_change_weight() {
439439
}
440440
// Test update value
441441
let mut indicies: Vec<_> = (0u32..200).collect();
442-
indicies.shuffle(&mut thread_rng());
442+
indicies.shuffle(&mut rng());
443443
for i in indicies {
444444
let should_fail = i % 3 == 0;
445445
let update = |node: &mut Node<_>| {
@@ -489,7 +489,7 @@ fn test_apply_op_change_key() {
489489
}
490490
// Test update value
491491
let mut indicies: Vec<_> = (0u32..200).collect();
492-
indicies.shuffle(&mut thread_rng());
492+
indicies.shuffle(&mut rng());
493493
for i in indicies {
494494
let should_fail = i % 3 == 0;
495495
let delete_item = i % 5 == 0;
@@ -578,7 +578,7 @@ fn test_apply_op_change_key_for_shared_key() {
578578
}
579579
// Test update value
580580
let mut indicies: Vec<_> = (0u32..200).collect();
581-
indicies.shuffle(&mut thread_rng());
581+
indicies.shuffle(&mut rng());
582582
for i in indicies {
583583
let should_fail = i % 3 == 0;
584584
let delete_item = i % 5 == 0;

0 commit comments

Comments
 (0)