diff --git a/src/key.rs b/src/key.rs index 9ca23d2..97ddc21 100644 --- a/src/key.rs +++ b/src/key.rs @@ -1572,6 +1572,7 @@ mod test { 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, ]; + #[cfg(not(fuzzing))] let s = Secp256k1::signing_only(); let sk = SecretKey::from_slice(&SK_BYTES).expect("sk"); @@ -1739,7 +1740,8 @@ mod test { assert_eq!(set.len(), COUNT); } - #[cfg_attr(not(fuzzing), test)] + #[test] + #[cfg(not(fuzzing))] fn pubkey_combine() { let compressed1 = PublicKey::from_slice( &hex!("0241cc121c419921942add6db6482fb36243faf83317c866d2a28d8c6d7089f7ba"), @@ -1759,7 +1761,8 @@ mod test { assert_eq!(sum1.unwrap(), exp_sum); } - #[cfg_attr(not(fuzzing), test)] + #[test] + #[cfg(not(fuzzing))] fn pubkey_combine_keys() { let compressed1 = PublicKey::from_slice( &hex!("0241cc121c419921942add6db6482fb36243faf83317c866d2a28d8c6d7089f7ba"), @@ -1782,7 +1785,8 @@ mod test { assert_eq!(sum1.unwrap(), exp_sum); } - #[cfg_attr(not(fuzzing), test)] + #[test] + #[cfg(not(fuzzing))] fn pubkey_combine_keys_empty_slice() { assert!(PublicKey::combine_keys(&[]).is_err()); } @@ -1852,6 +1856,7 @@ mod test { 0218845781f631c48f1c9709e23092067d06837f30aa0cd0544ac887fe91ddd166\ "; + #[cfg(not(fuzzing))] let s = Secp256k1::new(); let sk = SecretKey::from_slice(&SK_BYTES).unwrap(); diff --git a/src/schnorr.rs b/src/schnorr.rs index 14ac36f..ea536f5 100644 --- a/src/schnorr.rs +++ b/src/schnorr.rs @@ -286,7 +286,7 @@ mod tests { use super::*; - #[cfg(any(feature = "alloc", feature = "std"))] + #[cfg(all(not(fuzzing), any(feature = "alloc", feature = "std")))] macro_rules! hex_32 { ($hex:expr) => {{ let mut result = [0u8; 32]; @@ -458,19 +458,21 @@ mod tests { #[test] #[cfg(feature = "std")] fn test_pubkey_display_output() { - let secp = Secp256k1::new(); - static SK_BYTES: [u8; 32] = [ - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x63, 0x63, 0x63, 0x63, - 0x63, 0x63, 0x63, 0x63, - ]; - - let kp = KeyPair::from_seckey_slice(&secp, &SK_BYTES).expect("sk"); - - // In fuzzing mode secret->public key derivation is different, so - // hard-code the epected result. #[cfg(not(fuzzing))] - let pk = kp.public_key(); + let pk = { + let secp = Secp256k1::new(); + static SK_BYTES: [u8; 32] = [ + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x63, 0x63, 0x63, 0x63, + 0x63, 0x63, 0x63, 0x63, + ]; + + let kp = KeyPair::from_seckey_slice(&secp, &SK_BYTES).expect("sk"); + + // In fuzzing mode secret->public key derivation is different, so + // hard-code the epected result. + kp.public_key() + }; #[cfg(fuzzing)] let pk = XOnlyPublicKey::from_slice(&[0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f, 0x1c, 0x97, 0x09, 0xe2, 0x30, 0x92, 0x06, 0x7d, 0x06, 0x83, 0x7f, 0x30, 0xaa, 0x0c, 0xd0, 0x54, 0x4a, 0xc8, 0x87, 0xfe, 0x91, 0xdd, 0xd1, 0x66]).expect("pk");