Remove duplicated `#[cfg(test)]` conditions

Several macros used in tests had `#[cfg(test)]` condition on each of
them. This deduplicates them by putting them into a separate module and
reexporting (with one condition for module and one for re-export).
This commit is contained in:
Martin Habovstiak 2022-08-13 11:42:46 +02:00
parent 5548696521
commit 4dedf7d555
1 changed files with 10 additions and 10 deletions

View File

@ -119,19 +119,19 @@ macro_rules! debug_from_display {
pub(crate) use debug_from_display;
#[cfg(test)]
macro_rules! hex_script (($s:expr) => (<$crate::Script as core::str::FromStr>::from_str($s).unwrap()));
#[cfg(test)]
pub(crate) use hex_script;
pub(crate) use test_macros::*;
#[cfg(test)]
macro_rules! hex_hash (($h:ident, $s:expr) => ($h::from_slice(&<$crate::prelude::Vec<u8> as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap()));
#[cfg(test)]
pub(crate) use hex_hash;
mod test_macros {
macro_rules! hex_script (($s:expr) => (<$crate::Script as core::str::FromStr>::from_str($s).unwrap()));
pub(crate) use hex_script;
#[cfg(test)]
macro_rules! hex_decode (($h:ident, $s:expr) => (deserialize::<$h>(&<$crate::prelude::Vec<u8> as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap()));
#[cfg(test)]
pub(crate) use hex_decode;
macro_rules! hex_hash (($h:ident, $s:expr) => ($h::from_slice(&<$crate::prelude::Vec<u8> as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap()));
pub(crate) use hex_hash;
macro_rules! hex_decode (($h:ident, $s:expr) => (deserialize::<$h>(&<$crate::prelude::Vec<u8> as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap()));
pub(crate) use hex_decode;
}
macro_rules! serde_string_impl {
($name:ident, $expecting:literal) => {