From 0939aba57ea2a7aca59d2077f70a5d27b251ad3f Mon Sep 17 00:00:00 2001 From: Lucas Soriano del Pino Date: Fri, 17 Sep 2021 14:59:54 +1000 Subject: [PATCH] Remove rand_chacha We don't need to use seedable RNG in our tests. --- Cargo.lock | 1 - cfd_protocol/Cargo.toml | 3 +-- cfd_protocol/tests/cfds.rs | 16 +++++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ffd7ad..81a04e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -267,7 +267,6 @@ dependencies = [ "itertools", "proptest", "rand 0.6.5", - "rand_chacha 0.1.1", "secp256k1-zkp", ] diff --git a/cfd_protocol/Cargo.toml b/cfd_protocol/Cargo.toml index 0d787a2..baa62c2 100644 --- a/cfd_protocol/Cargo.toml +++ b/cfd_protocol/Cargo.toml @@ -9,8 +9,7 @@ bdk = { git = "https://github.com/bitcoindevkit/bdk/" } bit-vec = "0.6" itertools = "0.10" rand = "0.6" -rand_chacha = "0.1" -secp256k1-zkp = { git = "https://github.com/ElementsProject/rust-secp256k1-zkp", default-features = false, features = ["bitcoin_hashes", "global-context", "serde"] } +secp256k1-zkp = { git = "https://github.com/ElementsProject/rust-secp256k1-zkp", features = ["bitcoin_hashes", "global-context", "serde"] } [dev-dependencies] bitcoin = { version = "0.27", features = ["rand", "bitcoinconsensus"] } diff --git a/cfd_protocol/tests/cfds.rs b/cfd_protocol/tests/cfds.rs index 30a8397..2b9a4c9 100644 --- a/cfd_protocol/tests/cfds.rs +++ b/cfd_protocol/tests/cfds.rs @@ -13,13 +13,12 @@ use cfd_protocol::{ lock_descriptor, oracle, punish_transaction, renew_cfd_transactions, spending_tx_sighash, CfdTransactions, Payout, PunishParams, TransactionExt, WalletExt, }; -use rand::{CryptoRng, RngCore, SeedableRng}; -use rand_chacha::ChaChaRng; +use rand::{thread_rng, CryptoRng, RngCore}; use secp256k1_zkp::{schnorrsig, EcdsaAdaptorSignature, SecretKey, Signature, SECP256K1}; #[test] fn create_cfd() { - let mut rng = ChaChaRng::seed_from_u64(0); + let mut rng = thread_rng(); let maker_lock_amount = Amount::ONE_BTC; let taker_lock_amount = Amount::ONE_BTC; @@ -103,7 +102,7 @@ fn create_cfd() { #[test] fn renew_cfd() { - let mut rng = ChaChaRng::seed_from_u64(0); + let mut rng = thread_rng(); let maker_lock_amount = Amount::ONE_BTC; let taker_lock_amount = Amount::ONE_BTC; @@ -265,8 +264,8 @@ fn renew_cfd() { ) } -fn create_cfd_txs( - rng: &mut ChaChaRng, +fn create_cfd_txs( + rng: &mut R, (maker_wallet, maker_lock_amount): (&bdk::Wallet<(), bdk::database::MemoryDatabase>, Amount), (taker_wallet, taker_lock_amount): (&bdk::Wallet<(), bdk::database::MemoryDatabase>, Amount), oracle_pk: schnorrsig::PublicKey, @@ -279,7 +278,10 @@ fn create_cfd_txs( CfdKeys, Address, Address, -) { +) +where + R: RngCore + CryptoRng, +{ let (maker_sk, maker_pk) = make_keypair(rng); let (taker_sk, taker_pk) = make_keypair(rng);