From 128643d81e357157bfb3af3725bac653abfb402e Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Mon, 9 Nov 2020 21:29:25 -0300 Subject: [PATCH] Call `zebra_test::init` where needed. (#1227) * Add missing `zebra_test::init()` to zebra-chain * Add missing `zebra_test::init()` to zebra-consensus * Add missing `zebra_test::init()` to zebra-network * Add missing `zebra_test::init()` to zebra-state * Add missing `zebra_test::init()` to zebra-test * Add missing `zebra_test::init()` to zebrad --- zebra-chain/src/amount.rs | 17 ++++++++++++++++ zebra-chain/src/block/height.rs | 2 ++ zebra-chain/src/block/tests/prop.rs | 10 ++++++++++ zebra-chain/src/block/tests/vectors.rs | 20 +++++++++++++++++++ zebra-chain/src/parameters/tests.rs | 12 +++++++++++ zebra-chain/src/sapling/address.rs | 5 +++++ zebra-chain/src/sapling/commitment.rs | 12 +++++++++++ zebra-chain/src/sapling/keys/tests.rs | 4 ++++ zebra-chain/src/sapling/note/ciphertexts.rs | 2 ++ zebra-chain/src/sapling/tree.rs | 3 +++ zebra-chain/src/serialization/proptests.rs | 4 ++++ zebra-chain/src/serialization/sha256d.rs | 4 ++++ zebra-chain/src/sprout/address.rs | 4 ++++ zebra-chain/src/sprout/keys.rs | 6 ++++++ zebra-chain/src/sprout/note/ciphertexts.rs | 1 + zebra-chain/src/sprout/tree.rs | 4 ++++ zebra-chain/src/transaction/hash.rs | 2 ++ zebra-chain/src/transaction/memo.rs | 4 ++++ zebra-chain/src/transaction/tests/prop.rs | 6 ++++++ zebra-chain/src/transaction/tests/vectors.rs | 8 ++++++++ zebra-chain/src/transparent/address.rs | 13 ++++++++++++ zebra-chain/src/transparent/script.rs | 2 ++ zebra-chain/src/work/tests/prop.rs | 2 ++ .../src/block/subsidy/founders_reward.rs | 2 ++ zebra-consensus/src/block/subsidy/general.rs | 6 ++++++ zebra-consensus/src/block/tests.rs | 13 ++++++++++++ zebra-consensus/src/parameters/tests.rs | 1 + zebra-network/src/constants.rs | 4 ++++ zebra-network/src/meta_addr.rs | 2 ++ zebra-network/src/protocol/external/codec.rs | 5 +++++ zebra-network/src/protocol/external/types.rs | 8 ++++++++ zebra-state/src/tests.rs | 2 ++ zebra-test/src/vectors/block.rs | 6 ++++++ zebrad/src/components/sync.rs | 2 ++ zebrad/tests/acceptance.rs | 12 +++++++++++ 35 files changed, 210 insertions(+) diff --git a/zebra-chain/src/amount.rs b/zebra-chain/src/amount.rs index de644a46a..81a30b6fe 100644 --- a/zebra-chain/src/amount.rs +++ b/zebra-chain/src/amount.rs @@ -403,6 +403,7 @@ mod test { #[test] fn test_add_bare() -> Result<()> { zebra_test::init(); + let one: Amount = 1.try_into()?; let neg_one: Amount = (-1).try_into()?; @@ -417,6 +418,7 @@ mod test { #[test] fn test_add_opt_lhs() -> Result<()> { zebra_test::init(); + let one: Amount = 1.try_into()?; let one = Ok(one); let neg_one: Amount = (-1).try_into()?; @@ -432,6 +434,7 @@ mod test { #[test] fn test_add_opt_rhs() -> Result<()> { zebra_test::init(); + let one: Amount = 1.try_into()?; let neg_one: Amount = (-1).try_into()?; let neg_one = Ok(neg_one); @@ -447,6 +450,7 @@ mod test { #[test] fn test_add_opt_both() -> Result<()> { zebra_test::init(); + let one: Amount = 1.try_into()?; let one = Ok(one); let neg_one: Amount = (-1).try_into()?; @@ -463,6 +467,7 @@ mod test { #[test] fn test_add_assign() -> Result<()> { zebra_test::init(); + let one: Amount = 1.try_into()?; let neg_one: Amount = (-1).try_into()?; let mut neg_one = Ok(neg_one); @@ -479,6 +484,7 @@ mod test { #[test] fn test_sub_bare() -> Result<()> { zebra_test::init(); + let one: Amount = 1.try_into()?; let zero: Amount = 0.try_into()?; @@ -493,6 +499,7 @@ mod test { #[test] fn test_sub_opt_lhs() -> Result<()> { zebra_test::init(); + let one: Amount = 1.try_into()?; let one = Ok(one); let zero: Amount = 0.try_into()?; @@ -508,6 +515,7 @@ mod test { #[test] fn test_sub_opt_rhs() -> Result<()> { zebra_test::init(); + let one: Amount = 1.try_into()?; let zero: Amount = 0.try_into()?; let zero = Ok(zero); @@ -523,6 +531,7 @@ mod test { #[test] fn test_sub_assign() -> Result<()> { zebra_test::init(); + let one: Amount = 1.try_into()?; let zero: Amount = 0.try_into()?; let mut zero = Ok(zero); @@ -538,6 +547,8 @@ mod test { #[test] fn add_with_diff_constraints() -> Result<()> { + zebra_test::init(); + let one = Amount::::try_from(1)?; let zero = Amount::::try_from(0)?; @@ -549,6 +560,8 @@ mod test { #[test] fn deserialize_checks_bounds() -> Result<()> { + zebra_test::init(); + let big = MAX_MONEY * 2; let neg = -10; @@ -572,6 +585,8 @@ mod test { #[test] fn hash() -> Result<()> { + zebra_test::init(); + let one = Amount::::try_from(1)?; let another_one = Amount::::try_from(1)?; let zero = Amount::::try_from(0)?; @@ -601,6 +616,8 @@ mod test { #[test] fn ordering_constraints() -> Result<()> { + zebra_test::init(); + ordering::()?; ordering::()?; ordering::()?; diff --git a/zebra-chain/src/block/height.rs b/zebra-chain/src/block/height.rs index a9465db5f..0c11b2d74 100644 --- a/zebra-chain/src/block/height.rs +++ b/zebra-chain/src/block/height.rs @@ -132,6 +132,8 @@ impl Arbitrary for Height { #[test] fn operator_tests() { + zebra_test::init(); + assert_eq!(Some(Height(2)), Height(1) + Height(1)); assert_eq!(None, Height::MAX + Height(1)); // Bad heights aren't caught at compile-time or runtime, until we add or subtract diff --git a/zebra-chain/src/block/tests/prop.rs b/zebra-chain/src/block/tests/prop.rs index f202306fd..7cfee309e 100644 --- a/zebra-chain/src/block/tests/prop.rs +++ b/zebra-chain/src/block/tests/prop.rs @@ -12,6 +12,8 @@ use super::super::{serialize::MAX_BLOCK_BYTES, *}; proptest! { #[test] fn block_hash_roundtrip(hash in any::()) { + zebra_test::init(); + let bytes = hash.zcash_serialize_to_vec()?; let other_hash: Hash = bytes.zcash_deserialize_into()?; @@ -20,6 +22,8 @@ proptest! { #[test] fn block_hash_display_fromstr_roundtrip(hash in any::()) { + zebra_test::init(); + let display = format!("{}", hash); let parsed = display.parse::().expect("hash should parse"); prop_assert_eq!(hash, parsed); @@ -27,6 +31,8 @@ proptest! { #[test] fn blockheader_roundtrip(header in any::
()) { + zebra_test::init(); + let bytes = header.zcash_serialize_to_vec()?; let other_header = bytes.zcash_deserialize_into()?; @@ -39,6 +45,8 @@ proptest! { network in any::(), block_height in any::() ) { + zebra_test::init(); + let root_hash = RootHash::from_bytes(bytes, network, block_height); let other_bytes = root_hash.to_bytes(); @@ -56,6 +64,8 @@ proptest! { #[test] fn block_roundtrip(block in any::(), network in any::()) { + zebra_test::init(); + let bytes = block.zcash_serialize_to_vec()?; let bytes = &mut bytes.as_slice(); diff --git a/zebra-chain/src/block/tests/vectors.rs b/zebra-chain/src/block/tests/vectors.rs index 1dcfd9a8a..15a47e771 100644 --- a/zebra-chain/src/block/tests/vectors.rs +++ b/zebra-chain/src/block/tests/vectors.rs @@ -11,6 +11,8 @@ use super::generate; // XXX this should be rewritten as strategies #[test] fn blockheaderhash_debug() { + zebra_test::init(); + let preimage = b"foo bar baz"; let mut sha_writer = sha256d::Writer::default(); let _ = sha_writer.write_all(preimage); @@ -25,6 +27,8 @@ fn blockheaderhash_debug() { #[test] fn blockheaderhash_from_blockheader() { + zebra_test::init(); + let blockheader = generate::block_header(); let hash = Hash::from(&blockheader); @@ -69,6 +73,8 @@ fn deserialize_blockheader() { #[test] fn deserialize_block() { + zebra_test::init(); + // this one has a bad version field zebra_test::vectors::BLOCK_MAINNET_434873_BYTES .zcash_deserialize_into::() @@ -83,6 +89,8 @@ fn deserialize_block() { #[test] fn block_test_vectors_unique() { + zebra_test::init(); + let block_count = zebra_test::vectors::BLOCKS.len(); let block_hashes: HashSet<_> = zebra_test::vectors::BLOCKS .iter() @@ -103,11 +111,15 @@ fn block_test_vectors_unique() { #[test] fn block_test_vectors_height_mainnet() { + zebra_test::init(); + block_test_vectors_height(Network::Mainnet); } #[test] fn block_test_vectors_height_testnet() { + zebra_test::init(); + block_test_vectors_height(Network::Testnet); } @@ -131,6 +143,8 @@ fn block_test_vectors_height(network: Network) { #[test] fn block_limits_multi_tx() { + zebra_test::init(); + // Test multiple small transactions to fill a block max size // Create a block just below the limit @@ -166,6 +180,8 @@ fn block_limits_multi_tx() { #[test] fn block_limits_single_tx() { + zebra_test::init(); + // Test block limit with a big single transaction // Create a block just below the limit @@ -213,6 +229,8 @@ fn node_time_check( #[test] fn time_check_now() { + zebra_test::init(); + // These checks are deteministic, because all the times are offset // from the current time. let now = Utc::now(); @@ -273,6 +291,8 @@ static BLOCK_HEADER_INVALID_TIMESTAMPS: &[i64] = &[ #[test] fn time_check_fixed() { + zebra_test::init(); + // These checks are non-deterministic, but the times are all in the // distant past or far future. So it's unlikely that the test // machine will have a clock that makes these tests fail. diff --git a/zebra-chain/src/parameters/tests.rs b/zebra-chain/src/parameters/tests.rs index ad7345d60..33e5b6831 100644 --- a/zebra-chain/src/parameters/tests.rs +++ b/zebra-chain/src/parameters/tests.rs @@ -12,6 +12,8 @@ use NetworkUpgrade::*; /// Check that the activation heights and network upgrades are unique. #[test] fn activation_bijective() { + zebra_test::init(); + let mainnet_activations = NetworkUpgrade::activation_list(Mainnet); let mainnet_heights: HashSet<&block::Height> = mainnet_activations.keys().collect(); assert_eq!(MAINNET_ACTIVATION_HEIGHTS.len(), mainnet_heights.len()); @@ -29,11 +31,13 @@ fn activation_bijective() { #[test] fn activation_extremes_mainnet() { + zebra_test::init(); activation_extremes(Mainnet) } #[test] fn activation_extremes_testnet() { + zebra_test::init(); activation_extremes(Testnet) } @@ -84,11 +88,13 @@ fn activation_extremes(network: Network) { #[test] fn activation_consistent_mainnet() { + zebra_test::init(); activation_consistent(Mainnet) } #[test] fn activation_consistent_testnet() { + zebra_test::init(); activation_consistent(Testnet) } @@ -119,6 +125,8 @@ fn activation_consistent(network: Network) { /// Check that the network upgrades and branch ids are unique. #[test] fn branch_id_bijective() { + zebra_test::init(); + let branch_id_list = NetworkUpgrade::branch_id_list(); let nus: HashSet<&NetworkUpgrade> = branch_id_list.keys().collect(); assert_eq!(CONSENSUS_BRANCH_IDS.len(), nus.len()); @@ -129,11 +137,13 @@ fn branch_id_bijective() { #[test] fn branch_id_extremes_mainnet() { + zebra_test::init(); branch_id_extremes(Mainnet) } #[test] fn branch_id_extremes_testnet() { + zebra_test::init(); branch_id_extremes(Testnet) } @@ -165,11 +175,13 @@ fn branch_id_extremes(network: Network) { #[test] fn branch_id_consistent_mainnet() { + zebra_test::init(); branch_id_consistent(Mainnet) } #[test] fn branch_id_consistent_testnet() { + zebra_test::init(); branch_id_consistent(Testnet) } diff --git a/zebra-chain/src/sapling/address.rs b/zebra-chain/src/sapling/address.rs index 841f97c7a..2ee9e6ae5 100644 --- a/zebra-chain/src/sapling/address.rs +++ b/zebra-chain/src/sapling/address.rs @@ -119,6 +119,8 @@ mod tests { #[test] fn from_str_display() { + zebra_test::init(); + let zs_addr: Address = "zs1qqqqqqqqqqqqqqqqqrjq05nyfku05msvu49mawhg6kr0wwljahypwyk2h88z6975u563j8nfaxd" .parse() @@ -132,6 +134,8 @@ mod tests { #[test] fn derive_keys_and_addresses() { + zebra_test::init(); + let spending_key = keys::SpendingKey::new(&mut OsRng); let spend_authorizing_key = keys::SpendAuthorizingKey::from(spending_key); @@ -158,6 +162,7 @@ proptest! { #[test] fn sapling_address_roundtrip(zaddr in any::
()) { + zebra_test::init(); let string = zaddr.to_string(); diff --git a/zebra-chain/src/sapling/commitment.rs b/zebra-chain/src/sapling/commitment.rs index cd702d32c..562b83b1d 100644 --- a/zebra-chain/src/sapling/commitment.rs +++ b/zebra-chain/src/sapling/commitment.rs @@ -288,6 +288,8 @@ mod tests { #[test] fn pedersen_hash_to_point_test_vectors() { + zebra_test::init(); + const D: [u8; 8] = *b"Zcash_PH"; for test_vector in test_vectors::TEST_VECTORS.iter() { @@ -302,6 +304,8 @@ mod tests { #[test] fn add() { + zebra_test::init(); + let identity = ValueCommitment(jubjub::AffinePoint::identity()); let g = ValueCommitment(jubjub::AffinePoint::from_raw_unchecked( @@ -324,6 +328,8 @@ mod tests { #[test] fn add_assign() { + zebra_test::init(); + let mut identity = ValueCommitment(jubjub::AffinePoint::identity()); let g = ValueCommitment(jubjub::AffinePoint::from_raw_unchecked( @@ -349,6 +355,8 @@ mod tests { #[test] fn sub() { + zebra_test::init(); + let g_point = jubjub::AffinePoint::from_raw_unchecked( jubjub::Fq::from_raw([ 0xe4b3_d35d_f1a7_adfe, @@ -373,6 +381,8 @@ mod tests { #[test] fn sub_assign() { + zebra_test::init(); + let g_point = jubjub::AffinePoint::from_raw_unchecked( jubjub::Fq::from_raw([ 0xe4b3_d35d_f1a7_adfe, @@ -400,6 +410,8 @@ mod tests { #[test] fn sum() { + zebra_test::init(); + let g_point = jubjub::AffinePoint::from_raw_unchecked( jubjub::Fq::from_raw([ 0xe4b3_d35d_f1a7_adfe, diff --git a/zebra-chain/src/sapling/keys/tests.rs b/zebra-chain/src/sapling/keys/tests.rs index 252eae0df..8b8f43228 100644 --- a/zebra-chain/src/sapling/keys/tests.rs +++ b/zebra-chain/src/sapling/keys/tests.rs @@ -37,6 +37,8 @@ mod tests { #[test] fn derive_for_each_test_vector() { + zebra_test::init(); + for test_vector in test_vectors::TEST_VECTORS.iter() { let spending_key = SpendingKey::from(test_vector.sk); @@ -76,6 +78,8 @@ proptest! { #[test] fn string_roundtrips(spending_key in any::()) { + zebra_test::init(); + let sk_string = spending_key.to_string(); let spending_key_2: SpendingKey = sk_string.parse().unwrap(); prop_assert_eq![spending_key, spending_key_2]; diff --git a/zebra-chain/src/sapling/note/ciphertexts.rs b/zebra-chain/src/sapling/note/ciphertexts.rs index f5215d184..5f7b97586 100644 --- a/zebra-chain/src/sapling/note/ciphertexts.rs +++ b/zebra-chain/src/sapling/note/ciphertexts.rs @@ -107,6 +107,7 @@ proptest! { #[test] fn encrypted_ciphertext_roundtrip(ec in any::()) { + zebra_test::init(); let mut data = Vec::new(); @@ -119,6 +120,7 @@ proptest! { #[test] fn out_ciphertext_roundtrip(oc in any::()) { + zebra_test::init(); let mut data = Vec::new(); diff --git a/zebra-chain/src/sapling/tree.rs b/zebra-chain/src/sapling/tree.rs index 15e06f543..ad45b40fa 100644 --- a/zebra-chain/src/sapling/tree.rs +++ b/zebra-chain/src/sapling/tree.rs @@ -161,6 +161,8 @@ mod tests { #[test] fn empty_roots() { + zebra_test::init(); + // From https://github.com/zcash/librustzcash/blob/master/zcash_primitives/src/merkle_tree.rs#L512 const HEX_EMPTY_ROOTS: [&str; 33] = [ "0100000000000000000000000000000000000000000000000000000000000000", @@ -205,6 +207,7 @@ mod tests { #[test] fn incremental_roots() { + zebra_test::init(); // From https://github.com/zcash/zcash/blob/master/src/test/data/merkle_commitments_sapling.json // Byte-reversed from those ones because the original test vectors are loaded using uint256S() let commitments = [ diff --git a/zebra-chain/src/serialization/proptests.rs b/zebra-chain/src/serialization/proptests.rs index dda4b7637..99f2ec166 100644 --- a/zebra-chain/src/serialization/proptests.rs +++ b/zebra-chain/src/serialization/proptests.rs @@ -11,6 +11,8 @@ proptest! { #[test] fn compactsize_write_then_read_round_trip(s in 0u64..0x2_0000u64) { + zebra_test::init(); + // Maximum encoding size of a compactsize is 9 bytes. let mut buf = [0u8; 8+1]; Cursor::new(&mut buf[..]).write_compactsize(s).unwrap(); @@ -20,6 +22,8 @@ proptest! { #[test] fn compactsize_read_then_write_round_trip(bytes in prop::array::uniform9(0u8..)) { + zebra_test::init(); + // Only do the test if the bytes were valid. if let Ok(s) = Cursor::new(&bytes[..]).read_compactsize() { // The compactsize encoding is variable-length, so we may not even diff --git a/zebra-chain/src/serialization/sha256d.rs b/zebra-chain/src/serialization/sha256d.rs index 4b6acbfec..b861704da 100644 --- a/zebra-chain/src/serialization/sha256d.rs +++ b/zebra-chain/src/serialization/sha256d.rs @@ -60,6 +60,8 @@ mod tests { #[test] fn sha256d_checksum() { + zebra_test::init(); + // https://en.bitcoin.it/wiki/Protocol_documentation#Hashes let input = b"hello"; let checksum = Checksum::from(&input[..]); @@ -69,6 +71,8 @@ mod tests { #[test] fn sha256d_checksum_debug() { + zebra_test::init(); + let input = b"hello"; let checksum = Checksum::from(&input[..]); diff --git a/zebra-chain/src/sprout/address.rs b/zebra-chain/src/sprout/address.rs index 73c074cbb..bbe9f1c49 100644 --- a/zebra-chain/src/sprout/address.rs +++ b/zebra-chain/src/sprout/address.rs @@ -138,6 +138,8 @@ mod tests { #[test] fn from_string_debug() { + zebra_test::init(); + let string = "zcU1Cd6zYyZCd2VJF8yKgmzjxdiiU1rgTTjEwoN1CGUWCziPkUTXUjXmX7TMqdMNsTfuiGN1jQoVN4kGxUR4sAPN4XZ7pxb"; let zc_addr = string.parse::().unwrap(); @@ -150,6 +152,7 @@ proptest! { #[test] fn zcash_de_serialize_roundtrip(zaddr in any::()) { + zebra_test::init(); let mut data = Vec::new(); @@ -163,6 +166,7 @@ proptest! { #[test] fn zcash_base58check_roundtrip(zaddr in any::()) { + zebra_test::init(); let string = zaddr.to_string(); diff --git a/zebra-chain/src/sprout/keys.rs b/zebra-chain/src/sprout/keys.rs index e9c562a0c..59c5ed52e 100644 --- a/zebra-chain/src/sprout/keys.rs +++ b/zebra-chain/src/sprout/keys.rs @@ -344,6 +344,8 @@ mod tests { #[test] // TODO: test vectors, not just random data fn derive_keys() { + zebra_test::init(); + let spending_key = SpendingKey::new(&mut OsRng); let receiving_key = ReceivingKey::from(spending_key); @@ -357,6 +359,7 @@ proptest! { #[test] fn spending_key_roundtrip(sk in any::()) { + zebra_test::init(); let mut data = Vec::new(); @@ -370,6 +373,7 @@ proptest! { #[test] fn spending_key_string_roundtrip(sk in any::()) { + zebra_test::init(); let string = sk.to_string(); @@ -381,6 +385,7 @@ proptest! { #[test] fn incoming_viewing_key_roundtrip(ivk in any::()) { + zebra_test::init(); let mut data = Vec::new(); @@ -394,6 +399,7 @@ proptest! { #[test] fn incoming_viewing_key_string_roundtrip(ivk in any::()) { + zebra_test::init(); let string = ivk.to_string(); diff --git a/zebra-chain/src/sprout/note/ciphertexts.rs b/zebra-chain/src/sprout/note/ciphertexts.rs index 515355106..818ca0ef7 100644 --- a/zebra-chain/src/sprout/note/ciphertexts.rs +++ b/zebra-chain/src/sprout/note/ciphertexts.rs @@ -60,6 +60,7 @@ proptest! { #[test] fn encrypted_ciphertext_roundtrip(ec in any::()) { + zebra_test::init(); let mut data = Vec::new(); diff --git a/zebra-chain/src/sprout/tree.rs b/zebra-chain/src/sprout/tree.rs index e020c2310..10f9ec859 100644 --- a/zebra-chain/src/sprout/tree.rs +++ b/zebra-chain/src/sprout/tree.rs @@ -176,6 +176,8 @@ mod tests { #[test] fn empty_roots() { + zebra_test::init(); + // From https://github.com/zcash/zcash/blob/master/src/zcash/IncrementalMerkleTree.cpp#L439 let hex_empty_roots = [ "0000000000000000000000000000000000000000000000000000000000000000", @@ -217,6 +219,8 @@ mod tests { #[test] fn incremental_roots() { + zebra_test::init(); + // From https://github.com/zcash/zcash/blob/master/src/test/data/merkle_commitments.json // // Byte-reversed from those ones because the original test vectors are diff --git a/zebra-chain/src/transaction/hash.rs b/zebra-chain/src/transaction/hash.rs index 9b7511aaa..ae1e9ea8c 100644 --- a/zebra-chain/src/transaction/hash.rs +++ b/zebra-chain/src/transaction/hash.rs @@ -65,6 +65,8 @@ mod tests { #[test] fn transactionhash_from_str() { + zebra_test::init(); + let hash: Hash = "3166411bd5343e0b284a108f39a929fbbb62619784f8c6dafe520703b5b446bf" .parse() .unwrap(); diff --git a/zebra-chain/src/transaction/memo.rs b/zebra-chain/src/transaction/memo.rs index e5d0ad52e..6b09f7cb8 100644 --- a/zebra-chain/src/transaction/memo.rs +++ b/zebra-chain/src/transaction/memo.rs @@ -50,6 +50,8 @@ impl fmt::Debug for Memo { #[test] fn memo_fmt() { + zebra_test::init(); + let memo = Memo(Box::new( *b"thiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis \ iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis \ @@ -74,6 +76,8 @@ fn memo_fmt() { #[test] fn memo_from_string() { + zebra_test::init(); + let memo = Memo::try_from("foo bar baz".as_ref()).unwrap(); let mut bytes = [0; 512]; diff --git a/zebra-chain/src/transaction/tests/prop.rs b/zebra-chain/src/transaction/tests/prop.rs index 29548bbbf..97cf6fcf3 100644 --- a/zebra-chain/src/transaction/tests/prop.rs +++ b/zebra-chain/src/transaction/tests/prop.rs @@ -8,6 +8,8 @@ use crate::serialization::{ZcashDeserialize, ZcashDeserializeInto, ZcashSerializ proptest! { #[test] fn transaction_roundtrip(tx in any::()) { + zebra_test::init(); + let data = tx.zcash_serialize_to_vec().expect("tx should serialize"); let tx2 = data.zcash_deserialize_into().expect("randomized tx should deserialize"); @@ -16,6 +18,8 @@ proptest! { #[test] fn transaction_hash_display_fromstr_roundtrip(hash in any::()) { + zebra_test::init(); + let display = format!("{}", hash); let parsed = display.parse::().expect("hash should parse"); prop_assert_eq!(hash, parsed); @@ -23,6 +27,8 @@ proptest! { #[test] fn locktime_roundtrip(locktime in any::()) { + zebra_test::init(); + let mut bytes = Cursor::new(Vec::new()); locktime.zcash_serialize(&mut bytes)?; diff --git a/zebra-chain/src/transaction/tests/vectors.rs b/zebra-chain/src/transaction/tests/vectors.rs index 50265362b..62c585813 100644 --- a/zebra-chain/src/transaction/tests/vectors.rs +++ b/zebra-chain/src/transaction/tests/vectors.rs @@ -4,6 +4,8 @@ use crate::serialization::{ZcashDeserialize, ZcashSerialize}; #[test] fn librustzcash_tx_deserialize_and_round_trip() { + zebra_test::init(); + let tx = Transaction::zcash_deserialize(&zebra_test::vectors::GENERIC_TESTNET_TX[..]) .expect("transaction test vector from librustzcash should deserialize"); @@ -15,6 +17,8 @@ fn librustzcash_tx_deserialize_and_round_trip() { #[test] fn librustzcash_tx_hash() { + zebra_test::init(); + let tx = Transaction::zcash_deserialize(&zebra_test::vectors::GENERIC_TESTNET_TX[..]) .expect("transaction test vector from librustzcash should deserialize"); @@ -29,6 +33,8 @@ fn librustzcash_tx_hash() { #[test] fn zip143_deserialize_and_round_trip() { + zebra_test::init(); + let tx1 = Transaction::zcash_deserialize(&zebra_test::vectors::ZIP143_1[..]) .expect("transaction test vector from ZIP143 should deserialize"); @@ -50,6 +56,8 @@ fn zip143_deserialize_and_round_trip() { #[test] fn zip243_deserialize_and_round_trip() { + zebra_test::init(); + let tx1 = Transaction::zcash_deserialize(&zebra_test::vectors::ZIP243_1[..]) .expect("transaction test vector from ZIP243 should deserialize"); diff --git a/zebra-chain/src/transparent/address.rs b/zebra-chain/src/transparent/address.rs index 923007357..b52eb2686 100644 --- a/zebra-chain/src/transparent/address.rs +++ b/zebra-chain/src/transparent/address.rs @@ -257,6 +257,8 @@ mod tests { #[test] fn pubkey_mainnet() { + zebra_test::init(); + let pub_key = PublicKey::from_slice(&[ 3, 23, 183, 225, 206, 31, 159, 148, 195, 42, 67, 115, 146, 41, 248, 140, 11, 3, 51, 41, 111, 180, 110, 143, 114, 134, 88, 73, 198, 174, 52, 184, 78, @@ -270,6 +272,8 @@ mod tests { #[test] fn pubkey_testnet() { + zebra_test::init(); + let pub_key = PublicKey::from_slice(&[ 3, 23, 183, 225, 206, 31, 159, 148, 195, 42, 67, 115, 146, 41, 248, 140, 11, 3, 51, 41, 111, 180, 110, 143, 114, 134, 88, 73, 198, 174, 52, 184, 78, @@ -283,6 +287,8 @@ mod tests { #[test] fn empty_script_mainnet() { + zebra_test::init(); + let script = Script(vec![0; 20]); let t_addr = script.to_address(Network::Mainnet); @@ -292,6 +298,8 @@ mod tests { #[test] fn empty_script_testnet() { + zebra_test::init(); + let script = Script(vec![0; 20]); let t_addr = script.to_address(Network::Testnet); @@ -301,6 +309,8 @@ mod tests { #[test] fn from_string() { + zebra_test::init(); + let t_addr: Address = "t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd".parse().unwrap(); assert_eq!(format!("{}", t_addr), "t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd"); @@ -308,6 +318,8 @@ mod tests { #[test] fn debug() { + zebra_test::init(); + let t_addr: Address = "t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd".parse().unwrap(); assert_eq!( @@ -322,6 +334,7 @@ proptest! { #[test] fn transparent_address_roundtrip(taddr in any::
()) { + zebra_test::init(); let mut data = Vec::new(); diff --git a/zebra-chain/src/transparent/script.rs b/zebra-chain/src/transparent/script.rs index 1e92bda7f..d99914acd 100644 --- a/zebra-chain/src/transparent/script.rs +++ b/zebra-chain/src/transparent/script.rs @@ -53,6 +53,8 @@ mod proptests { proptest! { #[test] fn script_roundtrip(script in any::