Browse Source

Remove rand_chacha

We don't need to use seedable RNG in our tests.
no-contract-setup-message
Lucas Soriano del Pino 3 years ago
parent
commit
0939aba57e
No known key found for this signature in database GPG Key ID: EE611E973A1530E7
  1. 1
      Cargo.lock
  2. 3
      cfd_protocol/Cargo.toml
  3. 16
      cfd_protocol/tests/cfds.rs

1
Cargo.lock

@ -267,7 +267,6 @@ dependencies = [
"itertools",
"proptest",
"rand 0.6.5",
"rand_chacha 0.1.1",
"secp256k1-zkp",
]

3
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"] }

16
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<R>(
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);

Loading…
Cancel
Save