Remove rand-std dev-dependency from secp256k1
In order to get better test coverage we should not enable the secp26k1 feature "rand-std" in dev-dependencies but instead feature gate tests that depend on this feature.
This commit is contained in:
parent
f71335f971
commit
941083ec4e
|
@ -52,7 +52,7 @@ hashbrown = { version = "0.8", optional = true }
|
|||
serde_json = "1.0.0"
|
||||
serde_test = "1.0.19"
|
||||
serde_derive = "1.0.103"
|
||||
secp256k1 = { version = "0.25.0", features = [ "recovery", "rand-std" ] }
|
||||
secp256k1 = { version = "0.25.0", features = ["recovery"] }
|
||||
bincode = "1.3.1"
|
||||
|
||||
[[example]]
|
||||
|
@ -60,7 +60,7 @@ name = "bip32"
|
|||
|
||||
[[example]]
|
||||
name = "handshake"
|
||||
required-features = ["std"]
|
||||
required-features = ["std", "rand-std"]
|
||||
|
||||
[[example]]
|
||||
name = "ecdsa-psbt"
|
||||
|
@ -68,4 +68,4 @@ required-features = ["std", "bitcoinconsensus"]
|
|||
|
||||
[[example]]
|
||||
name = "taproot-psbt"
|
||||
required-features = ["std", "bitcoinconsensus"]
|
||||
required-features = ["std", "rand-std", "bitcoinconsensus"]
|
||||
|
|
|
@ -31,9 +31,9 @@ if [ "$DO_LINT" = true ]
|
|||
then
|
||||
cargo clippy --all-features --all-targets -- -D warnings
|
||||
cargo clippy --example bip32 -- -D warnings
|
||||
cargo clippy --example handshake -- -D warnings
|
||||
cargo clippy --example handshake --features=rand-std -- -D warnings
|
||||
cargo clippy --example ecdsa-psbt --features=bitcoinconsensus -- -D warnings
|
||||
cargo clippy --example taproot-psbt --features=bitcoinconsensus -- -D warnings
|
||||
cargo clippy --example taproot-psbt --features=rand-std,bitcoinconsensus -- -D warnings
|
||||
fi
|
||||
|
||||
echo "********* Testing std *************"
|
||||
|
@ -77,7 +77,7 @@ do
|
|||
done
|
||||
|
||||
cargo run --example ecdsa-psbt --features=bitcoinconsensus
|
||||
cargo run --example taproot-psbt --features=bitcoinconsensus
|
||||
cargo run --example taproot-psbt --features=rand-std,bitcoinconsensus
|
||||
|
||||
# Build the docs if told to (this only works with the nightly toolchain)
|
||||
if [ "$DO_DOCS" = true ]; then
|
||||
|
|
|
@ -816,7 +816,6 @@ mod tests {
|
|||
use super::{deserialize, serialize, Error, CheckedData, VarInt};
|
||||
use super::{Transaction, BlockHash, FilterHash, TxMerkleNode, TxOut, TxIn};
|
||||
use crate::consensus::{Encodable, deserialize_partial, Decodable};
|
||||
use secp256k1::rand::{thread_rng, Rng};
|
||||
#[cfg(feature = "std")]
|
||||
use crate::network::{Address, message_blockdata::Inventory};
|
||||
|
||||
|
@ -1088,7 +1087,10 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "rand-std")]
|
||||
fn serialization_round_trips() {
|
||||
use secp256k1::rand::{thread_rng, Rng};
|
||||
|
||||
macro_rules! round_trip {
|
||||
($($val_type:ty),*) => {
|
||||
$(
|
||||
|
|
|
@ -499,20 +499,23 @@ impl Decodable for MerkleBlock {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use core::cmp::min;
|
||||
|
||||
#[cfg(feature = "rand-std")]
|
||||
use secp256k1::rand::prelude::*;
|
||||
|
||||
use super::*;
|
||||
use crate::consensus::encode::{deserialize, serialize};
|
||||
use crate::hash_types::{TxMerkleNode, Txid};
|
||||
#[cfg(feature = "rand-std")]
|
||||
use crate::hash_types::TxMerkleNode;
|
||||
use crate::hashes::hex::{FromHex, ToHex};
|
||||
#[cfg(feature = "rand-std")]
|
||||
use crate::hashes::Hash;
|
||||
use crate::{merkle_tree, Block};
|
||||
use crate::{Block, Txid};
|
||||
|
||||
/// accepts `pmt_test_$num`
|
||||
#[cfg(feature = "rand-std")]
|
||||
fn pmt_test_from_name(name: &str) { pmt_test(name[9..].parse().unwrap()) }
|
||||
|
||||
#[cfg(feature = "rand-std")]
|
||||
macro_rules! pmt_tests {
|
||||
($($name:ident),* $(,)?) => {
|
||||
$(
|
||||
|
@ -523,6 +526,7 @@ mod tests {
|
|||
)*
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "rand-std")]
|
||||
pmt_tests!(
|
||||
pmt_test_1,
|
||||
pmt_test_4,
|
||||
|
@ -538,7 +542,11 @@ mod tests {
|
|||
pmt_test_4095
|
||||
);
|
||||
|
||||
#[cfg(feature = "rand-std")]
|
||||
fn pmt_test(tx_count: usize) {
|
||||
use core::cmp::min;
|
||||
use crate::merkle_tree;
|
||||
|
||||
let mut rng = thread_rng();
|
||||
// Create some fake tx ids
|
||||
let tx_ids = (1..=tx_count)
|
||||
|
@ -713,6 +721,7 @@ mod tests {
|
|||
assert_eq!(index.len(), 0);
|
||||
}
|
||||
|
||||
#[cfg(feature = "rand-std")]
|
||||
impl PartialMerkleTree {
|
||||
/// Flip one bit in one of the hashes - this should break the authentication
|
||||
fn damage(&mut self, rng: &mut ThreadRng) {
|
||||
|
|
|
@ -225,7 +225,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(feature = "secp-recovery", feature = "base64"))]
|
||||
#[cfg(all(feature = "secp-recovery", feature = "base64", feature = "rand-std"))]
|
||||
fn test_message_signature() {
|
||||
use core::str::FromStr;
|
||||
|
||||
|
|
Loading…
Reference in New Issue