Merge rust-bitcoin/rust-bitcoin#4055: hashes: Only enable hex/std, and hex/alloc when hex is
7c12d92bc3
Only enable hex/std, alloc when hex is (Jamil Lambert, PhD)11770cac1c
Add hashes to io dev-depencies and require hex (Jamil Lambert, PhD)e7c6564d38
Add missing hex feature gate (Jamil Lambert, PhD) Pull request description: `hex/std` and `hex/alloc` should only be included if optional dependency `hex` is enabled. A bunch of tests that need `hex` relied on an `alloc` feature gate to ensure `hex/alloc` was enabled. Add feature gates to the tests that require `hex`. Add `?` so `hex/alloc` or `hex/std` are only included if the optional feature `hex` is enabled. Audit rest of crates `Cargo.toml` files: no other cases found. Close #4035 ACKs for top commit: Kixunil: ACK7c12d92bc3
apoelstra: ACK 7c12d92bc3011e1305238f0f5d3b155a01875814; successfully ran local tests; Played with cargo a bit; `cargo tree` seems to confirm that you can mix dev and non-dev dependencies like this. Tree-SHA512: bd752d3c074dd8c93b09aa318d98ccb761b2f9baa2797566dd1d5f486349a92fbcd05787ddeb53d1f05ef0b29fbf559152f6373674fbec01e1251e74ad61e61f
This commit is contained in:
commit
3fb5275e16
|
@ -15,8 +15,8 @@ exclude = ["tests", "contrib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = ["alloc", "hex/std"]
|
std = ["alloc", "hex?/std"]
|
||||||
alloc = ["hex/alloc"]
|
alloc = ["hex?/alloc"]
|
||||||
serde = ["dep:serde", "hex"]
|
serde = ["dep:serde", "hex"]
|
||||||
# Smaller (but slower) implementation of sha256, sha512 and ripemd160
|
# Smaller (but slower) implementation of sha256, sha512 and ripemd160
|
||||||
small-hash = []
|
small-hash = []
|
||||||
|
|
|
@ -95,6 +95,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(bench)]
|
#[cfg(bench)]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
mod benches {
|
mod benches {
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ impl crate::HashEngine for HashEngine {
|
||||||
mod tests {
|
mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn test() {
|
fn test() {
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,7 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
mod tests {
|
mod tests {
|
||||||
use hex::prelude::{DisplayHex, FromHex};
|
use hex::prelude::{DisplayHex, FromHex};
|
||||||
|
|
||||||
|
|
|
@ -326,6 +326,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn newtype_fmt_roundtrip() {
|
fn newtype_fmt_roundtrip() {
|
||||||
use alloc::format;
|
use alloc::format;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn test() {
|
fn test() {
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn test() {
|
fn test() {
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ use crate::{sha256, HashEngine};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn test() {
|
fn test() {
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
|
@ -70,6 +71,7 @@ fn test() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn fmt_roundtrips() {
|
fn fmt_roundtrips() {
|
||||||
use alloc::format;
|
use alloc::format;
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn test() {
|
fn test() {
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn fmt_roundtrips() {
|
fn fmt_roundtrips() {
|
||||||
use alloc::format;
|
use alloc::format;
|
||||||
|
|
||||||
|
|
|
@ -182,10 +182,12 @@ mod tests {
|
||||||
|
|
||||||
// The digest created by sha256 hashing `&[0]` starting with `TEST_MIDSTATE`.
|
// The digest created by sha256 hashing `&[0]` starting with `TEST_MIDSTATE`.
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
const HASH_ZERO_BACKWARD: &str =
|
const HASH_ZERO_BACKWARD: &str =
|
||||||
"29589d5122ec666ab5b4695070b6debc63881a4f85d88d93ddc90078038213ed";
|
"29589d5122ec666ab5b4695070b6debc63881a4f85d88d93ddc90078038213ed";
|
||||||
// And the same thing, forward.
|
// And the same thing, forward.
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
const HASH_ZERO_FORWARD: &str =
|
const HASH_ZERO_FORWARD: &str =
|
||||||
"ed1382037800c9dd938dd8854f1a8863bcdeb6705069b4b56a66ec22519d5829";
|
"ed1382037800c9dd938dd8854f1a8863bcdeb6705069b4b56a66ec22519d5829";
|
||||||
|
|
||||||
|
@ -198,10 +200,12 @@ mod tests {
|
||||||
|
|
||||||
// We support manually implementing `Tag` and creating a tagged hash from it.
|
// We support manually implementing `Tag` and creating a tagged hash from it.
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
pub type TestHash = sha256t::Hash<TestHashTag>;
|
pub type TestHash = sha256t::Hash<TestHashTag>;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn manually_created_sha256t_hash_type() {
|
fn manually_created_sha256t_hash_type() {
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ impl crate::HashEngine for HashEngine {
|
||||||
mod tests {
|
mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn test() {
|
fn test() {
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn test() {
|
fn test() {
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ impl crate::HashEngine for HashEngine {
|
||||||
mod tests {
|
mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
#[cfg(feature = "hex")]
|
||||||
fn test() {
|
fn test() {
|
||||||
use alloc::string::ToString;
|
use alloc::string::ToString;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ internals = { package = "bitcoin-internals", version = "0.4.0" }
|
||||||
|
|
||||||
hashes = { package = "bitcoin_hashes", version = "0.16.0", default-features = false, optional = true }
|
hashes = { package = "bitcoin_hashes", version = "0.16.0", default-features = false, optional = true }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
hashes = { package = "bitcoin_hashes", version = "0.16.0", default-features = false, features = ["hex"] }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
Loading…
Reference in New Issue