Skip to content

Commit e98255c

Browse files
committed
Replace Rng + CryptoRng trait bounds with simply CryptoRng, remove RngCoreAndCrypto trait.
1 parent fc1c8cd commit e98255c

89 files changed

Lines changed: 329 additions & 361 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api-server/scanner-lib/src/sync/tests/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ struct MockRemoteNode {
150150
}
151151

152152
impl MockRemoteNode {
153-
fn new(rng: &mut (impl Rng + CryptoRng)) -> Self {
153+
fn new(rng: &mut impl CryptoRng) -> Self {
154154
let tf = Arc::new(Mutex::new(TestFramework::builder(rng).build()));
155155
Self { tf }
156156
}
@@ -199,12 +199,7 @@ impl RemoteNode for MockRemoteNode {
199199
}
200200
}
201201

202-
fn create_chain(
203-
node: &MockRemoteNode,
204-
rng: &mut (impl Rng + CryptoRng),
205-
parent: u64,
206-
count: usize,
207-
) {
202+
fn create_chain(node: &MockRemoteNode, rng: &mut impl CryptoRng, parent: u64, count: usize) {
208203
let mut tf = node.tf.lock().unwrap();
209204
let parent_id = tf.chainstate.get_block_id_from_height(parent.into()).unwrap().unwrap();
210205
tf.create_chain(&parent_id, count, rng).unwrap();
@@ -1038,7 +1033,7 @@ async fn reorg_locked_balance(#[case] seed: Seed) {
10381033

10391034
#[allow(clippy::too_many_arguments)]
10401035
fn create_block(
1041-
rng: &mut (impl Rng + CryptoRng),
1036+
rng: &mut impl CryptoRng,
10421037
tf: &mut TestFramework,
10431038
target_block_time: Duration,
10441039
prev_block_hash: Id<GenBlock>,

api-server/stack-test-suite/tests/v2/helpers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use randomness::{CryptoRng, Rng};
3434

3535
pub fn prepare_stake_pool(
3636
stake_pool_outpoint: UtxoOutPoint,
37-
rng: &mut (impl Rng + CryptoRng),
37+
rng: &mut impl CryptoRng,
3838
available_amount: &mut Amount,
3939
tf: &mut TestFramework,
4040
) -> (UtxoOutPoint, StakePoolData, PoolId, Block) {
@@ -83,7 +83,7 @@ pub fn prepare_stake_pool(
8383

8484
pub fn prepare_delegation(
8585
transfer_outpoint: UtxoOutPoint,
86-
rng: &mut (impl Rng + CryptoRng),
86+
rng: &mut impl CryptoRng,
8787
pool_id: PoolId,
8888
available_amount: Amount,
8989
destination: Option<Destination>,
@@ -113,7 +113,7 @@ pub fn prepare_delegation(
113113
}
114114

115115
pub fn stake_delegation(
116-
rng: &mut (impl Rng + CryptoRng),
116+
rng: &mut impl CryptoRng,
117117
available_amount: Amount,
118118
transfer_outpoint: UtxoOutPoint,
119119
delegation_id: DelegationId,
@@ -154,7 +154,7 @@ pub struct IssueAndMintTokensResult {
154154

155155
pub fn issue_and_mint_tokens_from_genesis(
156156
min_mint_amount: Amount,
157-
rng: &mut (impl Rng + CryptoRng),
157+
rng: &mut impl CryptoRng,
158158
tf: &mut TestFramework,
159159
) -> IssueAndMintTokensResult {
160160
let token_issuance_fee = tf.chainstate.get_chain_config().fungible_token_issuance_fee();

api-server/storage-test-suite/src/basic.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,10 +1943,7 @@ where
19431943
Ok(())
19441944
}
19451945

1946-
async fn orders<'a, S: for<'b> Transactional<'b>>(
1947-
rng: &mut (impl Rng + CryptoRng),
1948-
storage: &'a mut S,
1949-
) {
1946+
async fn orders<'a, S: for<'b> Transactional<'b>>(rng: &mut impl CryptoRng, storage: &'a mut S) {
19501947
let chain_config = common::chain::config::create_regtest();
19511948
{
19521949
let db_tx = storage.transaction_ro().await.unwrap();
@@ -2156,7 +2153,7 @@ async fn orders<'a, S: for<'b> Transactional<'b>>(
21562153
}
21572154

21582155
fn random_order(
2159-
rng: &mut (impl Rng + CryptoRng),
2156+
rng: &mut impl CryptoRng,
21602157
creation_height: BlockHeight,
21612158
ask_currency: CoinOrTokenId,
21622159
give_currency: CoinOrTokenId,

blockprod/src/detail/timestamp_searcher/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use consensus::{
3636
};
3737
use crypto::vrf::{VRFPrivateKey, VRFPublicKey};
3838
use logging::log;
39-
use randomness::{CryptoRng, Rng};
39+
use randomness::CryptoRng;
4040
use serialization::{Decode, Encode};
4141
use utils::{ensure, once_destructor::OnceDestructor, tokio_spawn_blocking};
4242

@@ -427,7 +427,7 @@ fn find_timestamps(
427427
final_supply: Amount,
428428
vrf_pub_key: &VRFPublicKey,
429429
vrf_prv_key: &VRFPrivateKey,
430-
rng: &mut (impl Rng + CryptoRng),
430+
rng: &mut impl CryptoRng,
431431
precomputed_hashes: Option<&PrecomputedHashes>,
432432
) -> Result<Vec<BlockTimestamp>, ConsensusPoSError> {
433433
let target = compact_target_to_target(search_data.target_required)?;

blockprod/src/detail/timestamp_searcher/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ mod collect_search_data {
370370

371371
fn make_test_framework(
372372
consensus_version: PoSConsensusVersion,
373-
rng: &mut (impl Rng + CryptoRng),
373+
rng: &mut impl CryptoRng,
374374
) -> TestFramework {
375375
let (staking_sk, staking_pk) = PrivateKey::new_from_rng(rng, KeyKind::Secp256k1Schnorr);
376376
let (vrf_sk, vrf_pk) = VRFPrivateKey::new_from_rng(rng, VRFKeyKind::Schnorrkel);
@@ -418,7 +418,7 @@ mod collect_search_data {
418418

419419
fn create_pool(
420420
tf: &mut TestFramework,
421-
rng: &mut (impl Rng + CryptoRng),
421+
rng: &mut impl CryptoRng,
422422
utxo_for_spending: &mut UtxoForSpending,
423423
) -> (PoolId, Amount) {
424424
let (_, vrf_pk) = VRFPrivateKey::new_from_rng(rng, VRFKeyKind::Schnorrkel);
@@ -442,7 +442,7 @@ mod collect_search_data {
442442

443443
fn delegate(
444444
tf: &mut TestFramework,
445-
rng: &mut (impl Rng + CryptoRng),
445+
rng: &mut impl CryptoRng,
446446
pool_id: &PoolId,
447447
utxo_for_spending: &mut UtxoForSpending,
448448
) -> Amount {

blockprod/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ mod tests {
359359
pub fn create_genesis_for_pos_tests(
360360
timestamp: BlockTimestamp,
361361
extra_txs: &[TxOutput],
362-
rng: &mut (impl Rng + CryptoRng),
362+
rng: &mut impl CryptoRng,
363363
) -> (
364364
Genesis,
365365
/*stake_private_key:*/ PrivateKey,
@@ -409,7 +409,7 @@ mod tests {
409409
time_getter: &TimeGetter,
410410
switch_to_pos_at: BlockHeight,
411411
extra_genesis_txs: &[TxOutput],
412-
rng: &mut (impl Rng + CryptoRng),
412+
rng: &mut impl CryptoRng,
413413
) -> (chain::config::Builder, PrivateKey, VRFPrivateKey, TxOutput) {
414414
let genesis_timestamp = make_genesis_timestamp(time_getter, rng);
415415
setup_pos_with_genesis_timestamp(
@@ -424,7 +424,7 @@ mod tests {
424424
genesis_timestamp: BlockTimestamp,
425425
switch_to_pos_at: BlockHeight,
426426
extra_genesis_txs: &[TxOutput],
427-
rng: &mut (impl Rng + CryptoRng),
427+
rng: &mut impl CryptoRng,
428428
) -> (chain::config::Builder, PrivateKey, VRFPrivateKey, TxOutput) {
429429
let initial_target = pos_initial_difficulty(ChainType::Regtest);
430430

chainstate/constraints-value-accumulator/src/tests/constraints_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use test_utils::{
4343

4444
use crate::{ConstrainedValueAccumulator, Error};
4545

46-
fn create_stake_pool_data(rng: &mut (impl Rng + CryptoRng), atoms_to_stake: u128) -> StakePoolData {
46+
fn create_stake_pool_data(rng: &mut impl CryptoRng, atoms_to_stake: u128) -> StakePoolData {
4747
let (_, vrf_pub_key) = VRFPrivateKey::new_from_rng(rng, VRFKeyKind::Schnorrkel);
4848
StakePoolData::new(
4949
Amount::from_atoms(atoms_to_stake),

chainstate/constraints-value-accumulator/src/tests/homomorphism.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use test_utils::{
3131

3232
use crate::ConstrainedValueAccumulator;
3333

34-
fn create_stake_pool_data(rng: &mut (impl Rng + CryptoRng), atoms_to_stake: u128) -> StakePoolData {
34+
fn create_stake_pool_data(rng: &mut impl CryptoRng, atoms_to_stake: u128) -> StakePoolData {
3535
let (_, vrf_pub_key) = VRFPrivateKey::new_from_rng(rng, VRFKeyKind::Schnorrkel);
3636
StakePoolData::new(
3737
Amount::from_atoms(atoms_to_stake),

chainstate/db-dumper/src/dumper_lib/tests/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl TestBlockInputInfo {
380380
fn from_rng(
381381
height: BlockHeight,
382382
is_mainchain: bool,
383-
rng: &mut (impl Rng + CryptoRng),
383+
rng: &mut impl CryptoRng,
384384
) -> TestBlockInputInfo {
385385
Self {
386386
height,
@@ -499,7 +499,7 @@ fn make_consensus_data(pool_id: PoolId, compact_target: Compact) -> ConsensusDat
499499
)))
500500
}
501501

502-
fn bogus_vrf_return(rng: &mut (impl Rng + CryptoRng)) -> VRFReturn {
502+
fn bogus_vrf_return(rng: &mut impl CryptoRng) -> VRFReturn {
503503
let (vrf_sk, _) = VRFPrivateKey::new_from_rng(rng, VRFKeyKind::Schnorrkel);
504504
let vrf_transcript = construct_transcript(
505505
rng.random(),
@@ -511,12 +511,12 @@ fn bogus_vrf_return(rng: &mut (impl Rng + CryptoRng)) -> VRFReturn {
511511
vrf_sk.produce_vrf_data(vrf_transcript)
512512
}
513513

514-
fn gen_compact_target(rng: &mut (impl Rng + CryptoRng)) -> Compact {
514+
fn gen_compact_target(rng: &mut impl CryptoRng) -> Compact {
515515
let target = Uint256::from_bytes(rng.random());
516516
target.into()
517517
}
518518

519-
fn gen_target(rng: &mut (impl Rng + CryptoRng)) -> Uint256 {
519+
fn gen_target(rng: &mut impl CryptoRng) -> Uint256 {
520520
gen_compact_target(rng).try_into().unwrap()
521521
}
522522

chainstate/storage/src/internal/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn test_storage_transactions_with_result_check(#[case] seed: Seed) {
298298
}
299299

300300
/// returns a tuple of utxo and outpoint, for testing.
301-
fn create_rand_utxo(rng: &mut (impl Rng + CryptoRng), block_height: u64) -> (Utxo, UtxoOutPoint) {
301+
fn create_rand_utxo(rng: &mut impl CryptoRng, block_height: u64) -> (Utxo, UtxoOutPoint) {
302302
// just a random value generated, and also a random `is_block_reward` value.
303303
let random_value = rng.random_range(0..(u128::MAX - 1));
304304
let (_, pub_key) = PrivateKey::new_from_rng(rng, KeyKind::Secp256k1Schnorr);
@@ -323,7 +323,7 @@ fn create_rand_utxo(rng: &mut (impl Rng + CryptoRng), block_height: u64) -> (Utx
323323
/// `max_lim_of_utxos` - sets the maximum limit of utxos of a random TxUndo.
324324
/// `max_lim_of_tx_undos` - the maximum limit of TxUndos in the BlockUndo.
325325
pub fn create_rand_block_undo(
326-
rng: &mut (impl Rng + CryptoRng),
326+
rng: &mut impl CryptoRng,
327327
max_lim_of_utxos: u8,
328328
max_lim_of_tx_undos: u8,
329329
) -> UtxosBlockUndo {

0 commit comments

Comments
 (0)