build(deps): bump insta from 1.15.0 to 1.17.1 (#4884)

* build(deps): bump insta from 1.15.0 to 1.17.1

Bumps [insta](https://github.com/mitsuhiko/insta) from 1.15.0 to 1.17.1.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.15.0...1.17.1)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* make zebra_test::init() return the insta drop guard

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Conrado Gouvea 2022-08-04 12:44:44 -03:00 committed by GitHub
parent f804ff6238
commit 6fd750e168
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
112 changed files with 610 additions and 601 deletions

16
Cargo.lock generated
View File

@ -843,9 +843,9 @@ dependencies = [
[[package]]
name = "console"
version = "0.15.0"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31"
checksum = "89eab4d20ce20cea182308bca13088fecea9c05f6776cf287205d41a0ed3c847"
dependencies = [
"encode_unicode",
"libc",
@ -2269,9 +2269,9 @@ dependencies = [
[[package]]
name = "insta"
version = "1.15.0"
version = "1.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4126dd76ebfe2561486a1bd6738a33d2029ffb068a99ac446b7f8c77b2e58dbc"
checksum = "1585a0f4924236ca3c8dac97bc6a3efaacc08b1ed9264ff2155ec7ab2906a8ea"
dependencies = [
"console",
"once_cell",
@ -4009,9 +4009,9 @@ dependencies = [
[[package]]
name = "ron"
version = "0.7.0"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b861ecaade43ac97886a512b360d01d66be9f41f3c61088b42cedf92e03d678"
checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a"
dependencies = [
"base64",
"bitflags",
@ -4418,9 +4418,9 @@ dependencies = [
[[package]]
name = "serde_yaml"
version = "0.8.23"
version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4a521f2940385c165a24ee286aa8599633d162077a54bdcae2a6fd5a7bfa7a0"
checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b"
dependencies = [
"indexmap",
"ryu",

View File

@ -55,7 +55,7 @@ where
#[tokio::test(flavor = "multi_thread")]
async fn batch_flushes_on_max_items() -> Result<(), Report> {
use tokio::time::timeout;
zebra_test::init();
let _init_guard = zebra_test::init();
// Use a very long max_latency and a short timeout to check that
// flushing is happening based on hitting max_items.
@ -73,7 +73,7 @@ async fn batch_flushes_on_max_items() -> Result<(), Report> {
#[tokio::test(flavor = "multi_thread")]
async fn batch_flushes_on_max_latency() -> Result<(), Report> {
use tokio::time::timeout;
zebra_test::init();
let _init_guard = zebra_test::init();
// Use a very high max_items and a short timeout to check that
// flushing is happening based on hitting max_latency.
@ -95,7 +95,7 @@ async fn batch_flushes_on_max_latency() -> Result<(), Report> {
#[tokio::test(flavor = "multi_thread")]
async fn fallback_verification() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Create our own verifier, so we don't shut down a shared verifier used by other tests.
let verifier = Fallback::new(

View File

@ -9,7 +9,7 @@ use tower_test::mock;
#[tokio::test]
async fn wakes_pending_waiters_on_close() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (service, mut handle) = mock::pair::<_, ()>();
@ -68,7 +68,7 @@ async fn wakes_pending_waiters_on_close() {
#[tokio::test]
async fn wakes_pending_waiters_on_failure() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (service, mut handle) = mock::pair::<_, ()>();

View File

@ -3,7 +3,7 @@ use tower_fallback::Fallback;
#[tokio::test]
async fn fallback() {
zebra_test::init();
let _init_guard = zebra_test::init();
// we'd like to use Transcript here but it can't handle errors :(

View File

@ -7,7 +7,7 @@ use crate::amount::*;
proptest! {
#[test]
fn amount_serialization(amount in any::<Amount<NegativeAllowed>>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let bytes = amount.to_bytes();
let serialized_amount = Amount::<NegativeAllowed>::from_bytes(bytes)?;
@ -17,7 +17,7 @@ proptest! {
#[test]
fn amount_deserialization(bytes in any::<[u8; 8]>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
if let Ok(deserialized) = Amount::<NegativeAllowed>::from_bytes(bytes) {
let bytes2 = deserialized.to_bytes();

View File

@ -10,7 +10,7 @@ use color_eyre::eyre::Result;
#[test]
fn test_add_bare() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one: Amount = 1.try_into()?;
let neg_one: Amount = (-1).try_into()?;
@ -25,7 +25,7 @@ fn test_add_bare() -> Result<()> {
#[test]
fn test_add_opt_lhs() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one: Amount = 1.try_into()?;
let one = Ok(one);
@ -41,7 +41,7 @@ fn test_add_opt_lhs() -> Result<()> {
#[test]
fn test_add_opt_rhs() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one: Amount = 1.try_into()?;
let neg_one: Amount = (-1).try_into()?;
@ -57,7 +57,7 @@ fn test_add_opt_rhs() -> Result<()> {
#[test]
fn test_add_opt_both() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one: Amount = 1.try_into()?;
let one = Ok(one);
@ -74,7 +74,7 @@ fn test_add_opt_both() -> Result<()> {
#[test]
fn test_add_assign() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one: Amount = 1.try_into()?;
let neg_one: Amount = (-1).try_into()?;
@ -91,7 +91,7 @@ fn test_add_assign() -> Result<()> {
#[test]
fn test_sub_bare() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one: Amount = 1.try_into()?;
let zero: Amount = Amount::zero();
@ -106,7 +106,7 @@ fn test_sub_bare() -> Result<()> {
#[test]
fn test_sub_opt_lhs() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one: Amount = 1.try_into()?;
let one = Ok(one);
@ -122,7 +122,7 @@ fn test_sub_opt_lhs() -> Result<()> {
#[test]
fn test_sub_opt_rhs() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one: Amount = 1.try_into()?;
let zero: Amount = Amount::zero();
@ -138,7 +138,7 @@ fn test_sub_opt_rhs() -> Result<()> {
#[test]
fn test_sub_assign() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one: Amount = 1.try_into()?;
let zero: Amount = Amount::zero();
@ -155,7 +155,7 @@ fn test_sub_assign() -> Result<()> {
#[test]
fn add_with_diff_constraints() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one = Amount::<NonNegative>::try_from(1)?;
let zero: Amount<NegativeAllowed> = Amount::zero();
@ -170,7 +170,7 @@ fn add_with_diff_constraints() -> Result<()> {
// The borrows are actually needed to call the correct trait impl
#[allow(clippy::needless_borrow)]
fn deserialize_checks_bounds() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let big = (MAX_MONEY * 2)
.try_into()
@ -205,7 +205,7 @@ fn deserialize_checks_bounds() -> Result<()> {
#[test]
fn hash() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one = Amount::<NonNegative>::try_from(1)?;
let another_one = Amount::<NonNegative>::try_from(1)?;
@ -233,7 +233,7 @@ fn hash() -> Result<()> {
#[test]
fn ordering_constraints() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
ordering::<NonNegative, NonNegative>()?;
ordering::<NonNegative, NegativeAllowed>()?;
@ -281,7 +281,7 @@ where
#[test]
fn test_sum() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let one: Amount = 1.try_into()?;
let neg_one: Amount = (-1).try_into()?;

View File

@ -146,7 +146,7 @@ impl ZcashDeserialize for Height {
#[test]
fn operator_tests() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Elementary checks.
assert_eq!(Some(Height(2)), Height(1) + Height(1));

View File

@ -23,7 +23,7 @@ const DEFAULT_BLOCK_ROUNDTRIP_PROPTEST_CASES: u32 = 16;
proptest! {
#[test]
fn block_hash_roundtrip(hash in any::<Hash>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let bytes = hash.zcash_serialize_to_vec()?;
let other_hash: Hash = bytes.zcash_deserialize_into()?;
@ -38,7 +38,7 @@ proptest! {
#[test]
fn block_hash_display_fromstr_roundtrip(hash in any::<Hash>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let display = format!("{}", hash);
let parsed = display.parse::<Hash>().expect("hash should parse");
@ -47,7 +47,7 @@ proptest! {
#[test]
fn block_hash_hex_roundtrip(hash in any::<Hash>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let hex_hash: String = hash.encode_hex();
let new_hash = Hash::from_hex(hex_hash).expect("hex hash should parse");
@ -56,7 +56,7 @@ proptest! {
#[test]
fn blockheader_roundtrip(header in any::<Header>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let bytes = header.zcash_serialize_to_vec()?;
let other_header = bytes.zcash_deserialize_into()?;
@ -75,7 +75,7 @@ proptest! {
network in any::<Network>(),
block_height in any::<Height>()
) {
zebra_test::init();
let _init_guard = zebra_test::init();
// just skip the test if the bytes don't parse, because there's nothing
// to compare with
@ -97,7 +97,7 @@ proptest! {
#[test]
fn block_roundtrip(block in any::<Block>(), network in any::<Network>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let bytes = block.zcash_serialize_to_vec()?;
@ -141,7 +141,7 @@ proptest! {
/// coinbase transactions.
#[test]
fn blocks_have_coinbase() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let strategy =
LedgerState::coinbase_strategy(None, None, false).prop_flat_map(Block::arbitrary_with);
@ -158,7 +158,7 @@ fn blocks_have_coinbase() -> Result<()> {
/// height and previous block hash.
#[test]
fn block_genesis_strategy() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let strategy =
LedgerState::genesis_strategy(None, None, false).prop_flat_map(Block::arbitrary_with);
@ -177,7 +177,7 @@ fn block_genesis_strategy() -> Result<()> {
/// - no transparent spends in the genesis block, because genesis transparent outputs are ignored
#[test]
fn genesis_partial_chain_strategy() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let strategy = LedgerState::genesis_strategy(None, None, false).prop_flat_map(|init| {
Block::partial_chain_strategy(
@ -225,7 +225,7 @@ fn genesis_partial_chain_strategy() -> Result<()> {
/// - correct previous block hashes
#[test]
fn arbitrary_height_partial_chain_strategy() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let strategy = any::<Height>()
.prop_flat_map(|height| LedgerState::height_strategy(height, None, None, false))

View File

@ -21,7 +21,7 @@ use super::generate; // XXX this should be rewritten as strategies
#[test]
fn blockheaderhash_debug() {
zebra_test::init();
let _init_guard = zebra_test::init();
let preimage = b"foo bar baz";
let mut sha_writer = sha256d::Writer::default();
@ -37,7 +37,7 @@ fn blockheaderhash_debug() {
#[test]
fn blockheaderhash_from_blockheader() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (blockheader, _blockheader_bytes) = generate::block_header();
@ -64,7 +64,7 @@ fn blockheaderhash_from_blockheader() {
#[test]
fn deserialize_blockheader() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Includes the 32-byte nonce and 3-byte equihash length field.
const BLOCK_HEADER_LENGTH: usize = crate::work::equihash::Solution::INPUT_LENGTH
@ -83,7 +83,7 @@ fn deserialize_blockheader() {
#[test]
fn round_trip_blocks() {
zebra_test::init();
let _init_guard = zebra_test::init();
// this one has a bad version field, but it is still valid
zebra_test::vectors::BLOCK_MAINNET_434873_BYTES
@ -106,7 +106,7 @@ fn round_trip_blocks() {
#[test]
fn coinbase_parsing_rejects_above_0x80() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::vectors::BAD_BLOCK_MAINNET_202_BYTES
.zcash_deserialize_into::<Block>()
@ -115,7 +115,7 @@ fn coinbase_parsing_rejects_above_0x80() {
#[test]
fn block_test_vectors_unique() {
zebra_test::init();
let _init_guard = zebra_test::init();
let block_count = zebra_test::vectors::BLOCKS.len();
let block_hashes: HashSet<_> = zebra_test::vectors::BLOCKS
@ -137,14 +137,14 @@ fn block_test_vectors_unique() {
#[test]
fn block_test_vectors_height_mainnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
block_test_vectors_height(Mainnet);
}
#[test]
fn block_test_vectors_height_testnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
block_test_vectors_height(Testnet);
}
@ -191,14 +191,14 @@ fn block_test_vectors_height(network: Network) {
#[test]
fn block_commitment_mainnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
block_commitment(Mainnet);
}
#[test]
fn block_commitment_testnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
block_commitment(Testnet);
}
@ -248,7 +248,7 @@ fn block_commitment(network: Network) {
#[test]
fn block_limits_multi_tx() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Test multiple small transactions to fill a block max size
@ -285,7 +285,7 @@ fn block_limits_multi_tx() {
#[test]
fn block_limits_single_tx() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Test block limit with a big single transaction
@ -334,7 +334,7 @@ fn node_time_check(
#[test]
fn time_check_now() {
zebra_test::init();
let _init_guard = zebra_test::init();
// These checks are deteministic, because all the times are offset
// from the current time.
@ -396,7 +396,7 @@ static BLOCK_HEADER_INVALID_TIMESTAMPS: &[i64] = &[
#[test]
fn time_check_fixed() {
zebra_test::init();
let _init_guard = 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

View File

@ -36,7 +36,7 @@ mod tests {
#[test]
fn derive_keys_and_addresses() {
zebra_test::init();
let _init_guard = zebra_test::init();
let network = Network::Mainnet;

View File

@ -322,7 +322,7 @@ mod tests {
// #[test]
// fn sinsemilla_hash_to_point_test_vectors() {
// zebra_test::init();
// let _init_guard = zebra_test::init();
// const D: [u8; 8] = *b"Zcash_PH";
@ -336,7 +336,7 @@ mod tests {
#[test]
fn add() {
zebra_test::init();
let _init_guard = zebra_test::init();
let identity = ValueCommitment(pallas::Affine::identity());
@ -347,7 +347,7 @@ mod tests {
#[test]
fn add_assign() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut identity = ValueCommitment(pallas::Affine::identity());
@ -361,7 +361,7 @@ mod tests {
#[test]
fn sub() {
zebra_test::init();
let _init_guard = zebra_test::init();
let g_point = pallas::Affine::generator();
@ -374,7 +374,7 @@ mod tests {
#[test]
fn sub_assign() {
zebra_test::init();
let _init_guard = zebra_test::init();
let g_point = pallas::Affine::generator();
@ -390,7 +390,7 @@ mod tests {
#[test]
fn sum() {
zebra_test::init();
let _init_guard = zebra_test::init();
let g_point = pallas::Affine::generator();

View File

@ -7,7 +7,7 @@ use proptest::prelude::*;
#[test]
fn generate_keys_from_test_vectors() {
zebra_test::init();
let _init_guard = zebra_test::init();
for test_vector in KEY_COMPONENTS.iter() {
let spending_key = SpendingKey::from_bytes(test_vector.sk, Network::Mainnet);
@ -53,7 +53,7 @@ proptest! {
#[test]
#[allow(clippy::clone_on_copy, clippy::cmp_owned)]
fn generate_keys(spending_key in any::<SpendingKey>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
// Test ConstantTimeEq, Eq, PartialEq
assert_eq!(spending_key, SpendingKey::from_bytes(spending_key.bytes, spending_key.network));

View File

@ -134,7 +134,7 @@ proptest! {
#[test]
fn encrypted_ciphertext_roundtrip(ec in any::<EncryptedNote>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut data = Vec::new();
@ -147,7 +147,7 @@ proptest! {
#[test]
fn out_ciphertext_roundtrip(oc in any::<WrappedNoteKey>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut data = Vec::new();

View File

@ -5,7 +5,7 @@ use crate::orchard::tree::*;
#[test]
fn empty_roots() {
zebra_test::init();
let _init_guard = zebra_test::init();
for i in 0..EMPTY_ROOTS.len() {
assert_eq!(
@ -18,7 +18,7 @@ fn empty_roots() {
#[test]
fn incremental_roots() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut leaves = vec![];

View File

@ -12,7 +12,7 @@ proptest! {
/// See [`ZIP_212_GRACE_PERIOD_DURATION`] for more information.
#[test]
fn mandatory_checkpoint_is_after_zip212_grace_period(network in any::<Network>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let canopy_activation = NetworkUpgrade::Canopy
.activation_height(network)

View File

@ -12,7 +12,7 @@ use NetworkUpgrade::*;
/// Check that the activation heights and network upgrades are unique.
#[test]
fn activation_bijective() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mainnet_activations = NetworkUpgrade::activation_list(Mainnet);
let mainnet_heights: HashSet<&block::Height> = mainnet_activations.keys().collect();
@ -31,13 +31,13 @@ fn activation_bijective() {
#[test]
fn activation_extremes_mainnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
activation_extremes(Mainnet)
}
#[test]
fn activation_extremes_testnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
activation_extremes(Testnet)
}
@ -108,13 +108,13 @@ fn activation_extremes(network: Network) {
#[test]
fn activation_consistent_mainnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
activation_consistent(Mainnet)
}
#[test]
fn activation_consistent_testnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
activation_consistent(Testnet)
}
@ -156,7 +156,7 @@ fn activation_consistent(network: Network) {
/// Check that the network upgrades and branch ids are unique.
#[test]
fn branch_id_bijective() {
zebra_test::init();
let _init_guard = zebra_test::init();
let branch_id_list = NetworkUpgrade::branch_id_list();
let nus: HashSet<&NetworkUpgrade> = branch_id_list.keys().collect();
@ -168,13 +168,13 @@ fn branch_id_bijective() {
#[test]
fn branch_id_extremes_mainnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
branch_id_extremes(Mainnet)
}
#[test]
fn branch_id_extremes_testnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
branch_id_extremes(Testnet)
}
@ -206,13 +206,13 @@ fn branch_id_extremes(network: Network) {
#[test]
fn branch_id_consistent_mainnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
branch_id_consistent(Mainnet)
}
#[test]
fn branch_id_consistent_testnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
branch_id_consistent(Testnet)
}
@ -241,7 +241,7 @@ use proptest::prelude::*;
proptest! {
#[test]
fn branch_id_hex_roundtrip(nu in any::<NetworkUpgrade>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
if let Some(branch) = nu.branch_id() {
let hex_branch: String = branch.encode_hex();

View File

@ -126,7 +126,7 @@ mod tests {
#[test]
fn from_str_display() {
zebra_test::init();
let _init_guard = zebra_test::init();
let zs_addr: Address =
"zs1qqqqqqqqqqqqqqqqqrjq05nyfku05msvu49mawhg6kr0wwljahypwyk2h88z6975u563j8nfaxd"
@ -141,7 +141,7 @@ mod tests {
#[test]
fn derive_keys_and_addresses() {
zebra_test::init();
let _init_guard = zebra_test::init();
let spending_key = keys::SpendingKey::new(&mut OsRng);
@ -170,7 +170,7 @@ proptest! {
#[test]
fn sapling_address_roundtrip(zaddr in any::<Address>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let string = zaddr.to_string();

View File

@ -374,7 +374,7 @@ mod tests {
#[test]
fn pedersen_hash_to_point_test_vectors() {
zebra_test::init();
let _init_guard = zebra_test::init();
const D: [u8; 8] = *b"Zcash_PH";
@ -390,7 +390,7 @@ mod tests {
#[test]
fn add() {
zebra_test::init();
let _init_guard = zebra_test::init();
let identity = ValueCommitment(jubjub::AffinePoint::identity());
@ -414,7 +414,7 @@ mod tests {
#[test]
fn add_assign() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut identity = ValueCommitment(jubjub::AffinePoint::identity());
@ -441,7 +441,7 @@ mod tests {
#[test]
fn sub() {
zebra_test::init();
let _init_guard = zebra_test::init();
let g_point = jubjub::AffinePoint::from_raw_unchecked(
jubjub::Fq::from_raw([
@ -467,7 +467,7 @@ mod tests {
#[test]
fn sub_assign() {
zebra_test::init();
let _init_guard = zebra_test::init();
let g_point = jubjub::AffinePoint::from_raw_unchecked(
jubjub::Fq::from_raw([
@ -496,7 +496,7 @@ mod tests {
#[test]
fn sum() {
zebra_test::init();
let _init_guard = zebra_test::init();
let g_point = jubjub::AffinePoint::from_raw_unchecked(
jubjub::Fq::from_raw([

View File

@ -37,7 +37,7 @@ mod tests {
#[test]
fn derive_for_each_test_vector() {
zebra_test::init();
let _init_guard = zebra_test::init();
for test_vector in test_vectors::TEST_VECTORS.iter() {
let spending_key = SpendingKey::from(test_vector.sk);
@ -79,7 +79,7 @@ proptest! {
#[test]
fn string_roundtrips(spending_key in any::<SpendingKey>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let sk_string = spending_key.to_string();
let spending_key_2: SpendingKey = sk_string.parse().unwrap();

View File

@ -109,7 +109,7 @@ proptest! {
#[test]
fn encrypted_ciphertext_roundtrip(ec in any::<EncryptedNote>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut data = Vec::new();
@ -122,7 +122,7 @@ proptest! {
#[test]
fn out_ciphertext_roundtrip(oc in any::<WrappedNoteKey>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut data = Vec::new();

View File

@ -16,7 +16,7 @@ proptest! {
fn spend_v4_roundtrip(
spend in any::<sapling::Spend<PerSpendAnchor>>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let data = spend.zcash_serialize_to_vec().expect("spend should serialize");
let spend_parsed = data.zcash_deserialize_into().expect("randomized spend should deserialize");
@ -33,7 +33,7 @@ proptest! {
fn spend_v5_roundtrip(
spend in any::<sapling::Spend<SharedAnchor>>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let (prefix, zkproof, spend_auth_sig) = spend.into_v5_parts();
@ -70,7 +70,7 @@ proptest! {
fn output_roundtrip(
output in any::<sapling::Output>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
// v4 format
let data = output.clone().into_v4().zcash_serialize_to_vec().expect("output should serialize");
@ -113,7 +113,7 @@ proptest! {
fn sapling_shielded_data_v4_roundtrip(
shielded_v4 in any::<sapling::ShieldedData<PerSpendAnchor>>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
// shielded data doesn't serialize by itself, so we have to stick it in
// a transaction
@ -142,7 +142,7 @@ proptest! {
fn sapling_shielded_data_v5_roundtrip(
shielded_v5 in any::<sapling::ShieldedData<SharedAnchor>>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let data = shielded_v5.zcash_serialize_to_vec().expect("shielded_v5 should serialize");
let shielded_v5_parsed = data.zcash_deserialize_into().expect("randomized shielded_v5 should deserialize");
@ -165,7 +165,7 @@ proptest! {
fn sapling_shielded_data_v4_outputs_only(
shielded_v4 in any::<sapling::ShieldedData<PerSpendAnchor>>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
// we need at least one output to delete all the spends
prop_assume!(shielded_v4.outputs().count() > 0);
@ -204,7 +204,7 @@ proptest! {
fn sapling_shielded_data_v5_outputs_only(
shielded_v5 in any::<sapling::ShieldedData<SharedAnchor>>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
// we need at least one output to delete all the spends
prop_assume!(shielded_v5.outputs().count() > 0);

View File

@ -15,7 +15,7 @@ use zebra_test::vectors::{
#[test]
fn empty_roots() {
zebra_test::init();
let _init_guard = zebra_test::init();
for i in 0..EMPTY_ROOTS.len() {
assert_eq!(
@ -28,7 +28,7 @@ fn empty_roots() {
#[test]
fn incremental_roots() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut leaves = vec![];

View File

@ -60,7 +60,7 @@ mod tests {
#[test]
fn sha256d_checksum() {
zebra_test::init();
let _init_guard = zebra_test::init();
// https://en.bitcoin.it/wiki/Protocol_documentation#Hashes
let input = b"hello";
@ -71,7 +71,7 @@ mod tests {
#[test]
fn sha256d_checksum_debug() {
zebra_test::init();
let _init_guard = zebra_test::init();
let input = b"hello";
let checksum = Checksum::from(&input[..]);

View File

@ -15,7 +15,7 @@ use crate::{
proptest! {
#[test]
fn compact_size_message_write_then_read_round_trip(size in any::<CompactSizeMessage>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let buf = size.zcash_serialize_to_vec().unwrap();
// Maximum encoding size of a CompactSize is 9 bytes.
@ -31,7 +31,7 @@ proptest! {
#[test]
fn compact_size_message_read_then_write_round_trip(bytes in prop::array::uniform9(0u8..)) {
zebra_test::init();
let _init_guard = zebra_test::init();
// Only do the test if the bytes were valid.
if let Ok(size) = CompactSizeMessage::zcash_deserialize(Cursor::new(&bytes[..])) {
@ -54,7 +54,7 @@ proptest! {
#[test]
fn compact_size_message_range(size in any::<usize>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
if let Ok(compact_size) = CompactSizeMessage::try_from(size) {
prop_assert!(size <= MAX_PROTOCOL_MESSAGE_LEN);
@ -68,7 +68,7 @@ proptest! {
#[test]
fn compact_size_64_write_then_read_round_trip(size in any::<CompactSize64>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let buf = size.zcash_serialize_to_vec().unwrap();
// Maximum encoding size of a CompactSize is 9 bytes.
@ -80,7 +80,7 @@ proptest! {
#[test]
fn compact_size_64_read_then_write_round_trip(bytes in prop::array::uniform9(0u8..)) {
zebra_test::init();
let _init_guard = zebra_test::init();
// Only do the test if the bytes were valid.
if let Ok(s) = CompactSize64::zcash_deserialize(Cursor::new(&bytes[..])) {
@ -99,7 +99,7 @@ proptest! {
#[test]
fn compact_size_64_conversion(size in any::<u64>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let compact_size = CompactSize64::from(size);
let compact_size: u64 = compact_size.into();
@ -108,7 +108,7 @@ proptest! {
#[test]
fn transaction_serialized_size(transaction in any::<UnminedTx>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
prop_assert_eq!(transaction.transaction.zcash_serialized_size().unwrap(), transaction.size);
}

View File

@ -136,7 +136,7 @@ mod tests {
#[test]
fn from_string_debug() {
zebra_test::init();
let _init_guard = zebra_test::init();
let string = "zcU1Cd6zYyZCd2VJF8yKgmzjxdiiU1rgTTjEwoN1CGUWCziPkUTXUjXmX7TMqdMNsTfuiGN1jQoVN4kGxUR4sAPN4XZ7pxb";
let zc_addr = string.parse::<SproutShieldedAddress>().unwrap();
@ -150,7 +150,7 @@ proptest! {
#[test]
fn zcash_de_serialize_roundtrip(zaddr in any::<SproutShieldedAddress>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut data = Vec::new();
@ -164,7 +164,7 @@ proptest! {
#[test]
fn zcash_base58check_roundtrip(zaddr in any::<SproutShieldedAddress>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let string = zaddr.to_string();

View File

@ -340,7 +340,7 @@ mod tests {
#[test]
// TODO: test vectors, not just random data
fn derive_keys() {
zebra_test::init();
let _init_guard = zebra_test::init();
let spending_key = SpendingKey::new(&mut OsRng);
@ -355,7 +355,7 @@ proptest! {
#[test]
fn spending_key_roundtrip(sk in any::<SpendingKey>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut data = Vec::new();
@ -369,7 +369,7 @@ proptest! {
#[test]
fn spending_key_string_roundtrip(sk in any::<SpendingKey>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let string = sk.to_string();
@ -381,7 +381,7 @@ proptest! {
#[test]
fn incoming_viewing_key_roundtrip(ivk in any::<IncomingViewingKey>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut data = Vec::new();
@ -395,7 +395,7 @@ proptest! {
#[test]
fn incoming_viewing_key_string_roundtrip(ivk in any::<IncomingViewingKey>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let string = ivk.to_string();

View File

@ -61,7 +61,7 @@ proptest! {
#[test]
fn encrypted_ciphertext_roundtrip(ec in any::<EncryptedNote>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut data = Vec::new();

View File

@ -18,7 +18,7 @@ use crate::sprout::tree;
/// Tests if empty roots are generated correctly.
#[test]
fn empty_roots() {
zebra_test::init();
let _init_guard = zebra_test::init();
for i in 0..tree::EMPTY_ROOTS.len() {
assert_eq!(
@ -41,7 +41,7 @@ fn empty_leaf() {
/// Tests if we can build the tree correctly.
#[test]
fn incremental_roots() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut leaves = vec![];

View File

@ -48,7 +48,7 @@ impl fmt::Debug for Memo {
#[test]
fn memo_fmt() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Rust changed the escaping of ' between 1.52 and 1.53 (nightly-2021-04-14?),
// so the memo string can't contain '
@ -78,7 +78,7 @@ fn memo_fmt() {
#[test]
fn memo_from_string() {
zebra_test::init();
let _init_guard = zebra_test::init();
let memo = Memo::try_from("foo bar baz".as_ref()).unwrap();

View File

@ -20,7 +20,7 @@ use crate::{
proptest! {
#[test]
fn transaction_roundtrip(tx in any::<Transaction>()) {
zebra_test::init();
let _init_guard = 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");
@ -36,7 +36,7 @@ proptest! {
#[test]
fn transaction_hash_struct_display_roundtrip(hash in any::<Hash>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let display = format!("{}", hash);
let parsed = display.parse::<Hash>().expect("hash should parse");
@ -45,7 +45,7 @@ proptest! {
#[test]
fn transaction_hash_string_parse_roundtrip(hash in any::<String>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
if let Ok(parsed) = hash.parse::<Hash>() {
let display = format!("{}", parsed);
@ -55,7 +55,7 @@ proptest! {
#[test]
fn transaction_hash_hex_roundtrip(hash in any::<Hash>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let hex_hash: String = hash.encode_hex();
let new_hash = Hash::from_hex(hex_hash).expect("hex hash should parse");
@ -64,7 +64,7 @@ proptest! {
#[test]
fn transaction_auth_digest_struct_display_roundtrip(auth_digest in any::<AuthDigest>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let display = format!("{}", auth_digest);
let parsed = display.parse::<AuthDigest>().expect("auth digest should parse");
@ -73,7 +73,7 @@ proptest! {
#[test]
fn transaction_auth_digest_string_parse_roundtrip(auth_digest in any::<String>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
if let Ok(parsed) = auth_digest.parse::<AuthDigest>() {
let display = format!("{}", parsed);
@ -83,7 +83,7 @@ proptest! {
#[test]
fn transaction_wtx_id_struct_display_roundtrip(wtx_id in any::<WtxId>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let display = format!("{}", wtx_id);
let parsed = display.parse::<WtxId>().expect("wide transaction ID should parse");
@ -92,7 +92,7 @@ proptest! {
#[test]
fn transaction_wtx_id_string_parse_roundtrip(wtx_id in any::<String>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
if let Ok(parsed) = wtx_id.parse::<WtxId>() {
let display = format!("{}", parsed);
@ -102,7 +102,7 @@ proptest! {
#[test]
fn locktime_roundtrip(locktime in any::<LockTime>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut bytes = Cursor::new(Vec::new());
locktime.zcash_serialize(&mut bytes)?;
@ -118,7 +118,7 @@ proptest! {
/// transaction versions.
#[test]
fn arbitrary_transaction_version_strategy() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Update with new transaction versions as needed
let strategy = (1..5u32)
@ -145,7 +145,7 @@ fn arbitrary_transaction_version_strategy() -> Result<()> {
/// with valid network upgrades.
#[test]
fn transaction_valid_network_upgrade_strategy() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Update with new transaction versions as needed
let strategy = LedgerState::coinbase_strategy(None, 5, true).prop_flat_map(|ledger_state| {

View File

@ -44,7 +44,7 @@ fn mock_pre_v5_output_list(output: transparent::Output, index: usize) -> Vec<tra
#[test]
fn transactionhash_struct_from_str_roundtrip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let hash: Hash = "3166411bd5343e0b284a108f39a929fbbb62619784f8c6dafe520703b5b446bf"
.parse()
@ -62,7 +62,7 @@ fn transactionhash_struct_from_str_roundtrip() {
#[test]
fn auth_digest_struct_from_str_roundtrip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let digest: AuthDigest = "3166411bd5343e0b284a108f39a929fbbb62619784f8c6dafe520703b5b446bf"
.parse()
@ -80,7 +80,7 @@ fn auth_digest_struct_from_str_roundtrip() {
#[test]
fn wtx_id_struct_from_str_roundtrip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let wtx_id: WtxId = "3166411bd5343e0b284a108f39a929fbbb62619784f8c6dafe520703b5b446bf0000000000000000000000000000000000000000000000000000000000000001"
.parse()
@ -98,7 +98,7 @@ fn wtx_id_struct_from_str_roundtrip() {
#[test]
fn librustzcash_tx_deserialize_and_round_trip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let tx = Transaction::zcash_deserialize(&zebra_test::vectors::GENERIC_TESTNET_TX[..])
.expect("transaction test vector from librustzcash should deserialize");
@ -111,7 +111,7 @@ fn librustzcash_tx_deserialize_and_round_trip() {
#[test]
fn librustzcash_tx_hash() {
zebra_test::init();
let _init_guard = zebra_test::init();
let tx = Transaction::zcash_deserialize(&zebra_test::vectors::GENERIC_TESTNET_TX[..])
.expect("transaction test vector from librustzcash should deserialize");
@ -127,7 +127,7 @@ fn librustzcash_tx_hash() {
#[test]
fn doesnt_deserialize_transaction_with_invalid_value_balance() {
zebra_test::init();
let _init_guard = zebra_test::init();
let dummy_transaction = Transaction::V4 {
inputs: vec![],
@ -158,7 +158,7 @@ fn doesnt_deserialize_transaction_with_invalid_value_balance() {
#[test]
fn zip143_deserialize_and_round_trip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let tx1 = Transaction::zcash_deserialize(&zebra_test::vectors::ZIP143_1[..])
.expect("transaction test vector from ZIP143 should deserialize");
@ -181,7 +181,7 @@ fn zip143_deserialize_and_round_trip() {
#[test]
fn zip243_deserialize_and_round_trip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let tx1 = Transaction::zcash_deserialize(&zebra_test::vectors::ZIP243_1[..])
.expect("transaction test vector from ZIP243 should deserialize");
@ -213,7 +213,7 @@ fn zip243_deserialize_and_round_trip() {
#[test]
fn deserialize_large_transaction() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Create a dummy input and output.
let input =
@ -273,7 +273,7 @@ fn deserialize_large_transaction() {
/// zebra_consensus::transaction::Verifier
#[test]
fn empty_v5_round_trip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let tx: &Transaction = &EMPTY_V5_TX;
@ -297,7 +297,7 @@ fn empty_v5_round_trip() {
/// zebra_consensus::transaction::Verifier
#[test]
fn empty_v4_round_trip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let tx = Transaction::V4 {
inputs: Vec::new(),
@ -325,7 +325,7 @@ fn empty_v4_round_trip() {
/// Check if an empty V5 transaction can be deserialized by librustzcash too.
#[test]
fn empty_v5_librustzcash_round_trip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let tx: &Transaction = &EMPTY_V5_TX;
let _alt_tx: zcash_primitives::transaction::Transaction = tx.try_into().expect(
@ -341,7 +341,7 @@ fn empty_v5_librustzcash_round_trip() {
/// transactions.
#[test]
fn fake_v5_round_trip() {
zebra_test::init();
let _init_guard = zebra_test::init();
fake_v5_round_trip_for_network(Network::Mainnet);
fake_v5_round_trip_for_network(Network::Testnet);
@ -463,7 +463,7 @@ fn fake_v5_round_trip_for_network(network: Network) {
#[test]
fn invalid_orchard_nullifier() {
zebra_test::init();
let _init_guard = zebra_test::init();
use std::convert::TryFrom;
@ -492,7 +492,7 @@ fn invalid_orchard_nullifier() {
/// Makes sure that zebra-serialized transactions can be deserialized by librustzcash.
#[test]
fn fake_v5_librustzcash_round_trip() {
zebra_test::init();
let _init_guard = zebra_test::init();
fake_v5_librustzcash_round_trip_for_network(Network::Mainnet);
fake_v5_librustzcash_round_trip_for_network(Network::Testnet);
@ -565,7 +565,7 @@ fn fake_v5_librustzcash_round_trip_for_network(network: Network) {
#[test]
fn zip244_round_trip() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
for test in zip0244::TEST_VECTORS.iter() {
let transaction = test.tx.zcash_deserialize_into::<Transaction>()?;
@ -584,7 +584,7 @@ fn zip244_round_trip() -> Result<()> {
#[test]
fn zip244_txid() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
for test in zip0244::TEST_VECTORS.iter() {
let transaction = test.tx.zcash_deserialize_into::<Transaction>()?;
@ -598,7 +598,7 @@ fn zip244_txid() -> Result<()> {
#[test]
fn zip244_auth_digest() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
for test in zip0244::TEST_VECTORS.iter() {
let transaction = test.tx.zcash_deserialize_into::<Transaction>()?;
@ -616,7 +616,7 @@ fn zip244_auth_digest() -> Result<()> {
#[test]
fn test_vec143_1() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let transaction = ZIP143_1.zcash_deserialize_into::<Transaction>()?;
@ -645,7 +645,7 @@ fn test_vec143_1() -> Result<()> {
#[test]
fn test_vec143_2() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let transaction = ZIP143_2.zcash_deserialize_into::<Transaction>()?;
@ -681,7 +681,7 @@ fn test_vec143_2() -> Result<()> {
#[test]
fn test_vec243_1() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let transaction = ZIP243_1.zcash_deserialize_into::<Transaction>()?;
@ -720,7 +720,7 @@ fn test_vec243_1() -> Result<()> {
#[test]
fn test_vec243_2() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let transaction = ZIP243_2.zcash_deserialize_into::<Transaction>()?;
@ -770,7 +770,7 @@ fn test_vec243_2() -> Result<()> {
#[test]
fn test_vec243_3() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let transaction = ZIP243_3.zcash_deserialize_into::<Transaction>()?;
@ -822,7 +822,7 @@ fn test_vec243_3() -> Result<()> {
#[test]
fn zip143_sighash() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
for (i, test) in zip0143::TEST_VECTORS.iter().enumerate() {
let transaction = test.tx.zcash_deserialize_into::<Transaction>()?;
@ -858,7 +858,7 @@ fn zip143_sighash() -> Result<()> {
#[test]
fn zip243_sighash() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
for (i, test) in zip0243::TEST_VECTORS.iter().enumerate() {
let transaction = test.tx.zcash_deserialize_into::<Transaction>()?;
@ -894,7 +894,7 @@ fn zip243_sighash() -> Result<()> {
#[test]
fn zip244_sighash() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
for (i, test) in zip0244::TEST_VECTORS.iter().enumerate() {
let transaction = test.tx.zcash_deserialize_into::<Transaction>()?;
@ -935,7 +935,7 @@ fn zip244_sighash() -> Result<()> {
#[test]
fn binding_signatures() {
zebra_test::init();
let _init_guard = zebra_test::init();
binding_signatures_for_network(Network::Mainnet);
binding_signatures_for_network(Network::Testnet);

View File

@ -260,7 +260,7 @@ mod tests {
#[test]
fn pubkey_mainnet() {
zebra_test::init();
let _init_guard = 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,
@ -275,7 +275,7 @@ mod tests {
#[test]
fn pubkey_testnet() {
zebra_test::init();
let _init_guard = 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,
@ -290,7 +290,7 @@ mod tests {
#[test]
fn empty_script_mainnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
let script = Script::new(&[0u8; 20]);
@ -301,7 +301,7 @@ mod tests {
#[test]
fn empty_script_testnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
let script = Script::new(&[0; 20]);
@ -312,7 +312,7 @@ mod tests {
#[test]
fn from_string() {
zebra_test::init();
let _init_guard = zebra_test::init();
let t_addr: Address = "t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd".parse().unwrap();
@ -321,7 +321,7 @@ mod tests {
#[test]
fn debug() {
zebra_test::init();
let _init_guard = zebra_test::init();
let t_addr: Address = "t3Vz22vK5z2LcKEdg16Yv4FFneEL1zg9ojd".parse().unwrap();
@ -337,7 +337,7 @@ proptest! {
#[test]
fn transparent_address_roundtrip(taddr in any::<Address>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut data = Vec::new();

View File

@ -100,7 +100,7 @@ mod proptests {
proptest! {
#[test]
fn script_roundtrip(script in any::<Script>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut bytes = Cursor::new(Vec::new());
script.zcash_serialize(&mut bytes)?;

View File

@ -13,7 +13,7 @@ use proptest::collection::vec;
#[test]
fn coinbase_has_height() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let strategy =
any::<block::Height>().prop_flat_map(|height| Input::arbitrary_with(Some(height)));
@ -28,7 +28,7 @@ fn coinbase_has_height() -> Result<()> {
#[test]
fn input_coinbase_vecs_only_have_coinbase_input() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let strategy = LedgerState::coinbase_strategy(None, None, false)
.prop_flat_map(|ledger_state| Input::vec_strategy(ledger_state, MAX_ARBITRARY_ITEMS));
@ -51,7 +51,7 @@ fn input_coinbase_vecs_only_have_coinbase_input() -> Result<()> {
#[test]
fn coinbase_height_round_trip_from_random_input() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let strategy =
any::<block::Height>().prop_flat_map(|height| Input::arbitrary_with(Some(height)));

View File

@ -11,7 +11,7 @@ use zebra_test::prelude::*;
#[test]
fn parse_coinbase_height_mins() {
zebra_test::init();
let _init_guard = zebra_test::init();
// examples with height 1:
@ -49,7 +49,7 @@ fn parse_coinbase_height_mins() {
#[test]
fn get_transparent_output_address() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let script_tx: Vec<u8> = <Vec<u8>>::from_hex("0400008085202f8901fcaf44919d4a17f6181a02a7ebe0420be6f7dad1ef86755b81d5a9567456653c010000006a473044022035224ed7276e61affd53315eca059c92876bc2df61d84277cafd7af61d4dbf4002203ed72ea497a9f6b38eb29df08e830d99e32377edb8a574b8a289024f0241d7c40121031f54b095eae066d96b2557c1f99e40e967978a5fd117465dbec0986ca74201a6feffffff020050d6dc0100000017a9141b8a9bda4b62cd0d0582b55455d0778c86f8628f870d03c812030000001976a914e4ff5512ffafe9287992a1cd177ca6e408e0300388ac62070d0095070d000000000000000000000000")
.expect("Block bytes are in valid hex representation");
@ -83,7 +83,7 @@ fn get_transparent_output_address() -> Result<()> {
#[test]
fn get_transparent_output_address_with_blocks() {
zebra_test::init();
let _init_guard = zebra_test::init();
get_transparent_output_address_with_blocks_for_network(Network::Mainnet);
get_transparent_output_address_with_blocks_for_network(Network::Testnet);

View File

@ -10,7 +10,7 @@ proptest! {
value_balance1 in any::<ValueBalance<NegativeAllowed>>(),
value_balance2 in any::<ValueBalance<NegativeAllowed>>())
{
zebra_test::init();
let _init_guard = zebra_test::init();
let transparent = value_balance1.transparent + value_balance2.transparent;
let sprout = value_balance1.sprout + value_balance2.sprout;
@ -43,7 +43,7 @@ proptest! {
value_balance1 in any::<ValueBalance<NegativeAllowed>>(),
value_balance2 in any::<ValueBalance<NegativeAllowed>>())
{
zebra_test::init();
let _init_guard = zebra_test::init();
let transparent = value_balance1.transparent - value_balance2.transparent;
let sprout = value_balance1.sprout - value_balance2.sprout;
@ -77,7 +77,7 @@ proptest! {
value_balance1 in any::<ValueBalance<NegativeAllowed>>(),
value_balance2 in any::<ValueBalance<NegativeAllowed>>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let collection = vec![value_balance1, value_balance2];
@ -107,7 +107,7 @@ proptest! {
#[test]
fn value_balance_serialization(value_balance in any::<ValueBalance<NonNegative>>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
let bytes = value_balance.to_bytes();
let serialized_value_balance = ValueBalance::from_bytes(bytes)?;
@ -117,7 +117,7 @@ proptest! {
#[test]
fn value_balance_deserialization(bytes in any::<[u8; 32]>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
if let Ok(deserialized) = ValueBalance::<NonNegative>::from_bytes(bytes) {
let bytes2 = deserialized.to_bytes();

View File

@ -15,7 +15,7 @@ const OFFSET: i32 = CompactDifficulty::OFFSET;
/// Test debug formatting.
#[test]
fn debug_format() {
zebra_test::init();
let _init_guard = zebra_test::init();
assert_eq!(
format!("{:?}", CompactDifficulty(0)),
@ -76,7 +76,7 @@ fn debug_format() {
/// Test zero values for CompactDifficulty.
#[test]
fn compact_zero() {
zebra_test::init();
let _init_guard = zebra_test::init();
let natural_zero = CompactDifficulty(0);
assert_eq!(natural_zero.to_expanded(), None);
@ -108,7 +108,7 @@ fn compact_zero() {
/// Test extreme values for CompactDifficulty.
#[test]
fn compact_extremes() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Values equal to one
let expanded_one = Some(ExpandedDifficulty(U256::one()));
@ -233,7 +233,7 @@ static COMPACT_DIFFICULTY_CASES: &[(u32, Option<u128>, Option<u128>)] = &[
#[test]
#[spandoc::spandoc]
fn compact_bitcoin_test_vectors() {
zebra_test::init();
let _init_guard = zebra_test::init();
// We use two spans, so we can diagnose conversion panics, and mismatching results
for (compact, expected_expanded, expected_work) in COMPACT_DIFFICULTY_CASES.iter().cloned() {
@ -271,7 +271,7 @@ fn block_difficulty() -> Result<(), Report> {
#[spandoc::spandoc]
fn block_difficulty_for_network(network: Network) -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block_iter = match network {
Network::Mainnet => zebra_test::vectors::MAINNET_BLOCKS.iter(),
@ -360,7 +360,7 @@ fn genesis_block_difficulty() -> Result<(), Report> {
#[spandoc::spandoc]
fn genesis_block_difficulty_for_network(network: Network) -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block = match network {
Network::Mainnet => zebra_test::vectors::MAINNET_BLOCKS.get(&0),
@ -499,7 +499,7 @@ fn check_testnet_minimum_difficulty_block(height: block::Height) -> Result<(), R
#[spandoc::spandoc]
#[allow(clippy::eq_op)]
fn expanded_order() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let zero = ExpandedDifficulty(U256::zero());
let one = ExpandedDifficulty(U256::one());
@ -521,7 +521,7 @@ fn expanded_order() -> Result<(), Report> {
#[test]
#[spandoc::spandoc]
fn expanded_hash_order() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let ex_zero = ExpandedDifficulty(U256::zero());
let ex_one = ExpandedDifficulty(U256::one());

View File

@ -13,7 +13,7 @@ const DEFAULT_TEST_INPUT_PROPTEST_CASES: u32 = 64;
#[test]
fn equihash_solution_roundtrip() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(solution in any::<equihash::Solution>())| {
let data = solution
@ -44,7 +44,7 @@ prop_compose! {
#[test]
fn equihash_prop_test_solution() -> color_eyre::eyre::Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
for block_bytes in zebra_test::vectors::BLOCKS.iter() {
let block = Block::zcash_deserialize(&block_bytes[..])
@ -84,7 +84,7 @@ prop_compose! {
#[test]
fn equihash_prop_test_nonce() -> color_eyre::eyre::Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
for block_bytes in zebra_test::vectors::BLOCKS.iter() {
let block = Block::zcash_deserialize(&block_bytes[..])
@ -120,7 +120,7 @@ prop_compose! {
#[test]
fn equihash_prop_test_input() -> color_eyre::eyre::Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
for block_bytes in zebra_test::vectors::BLOCKS.iter() {
let block = Block::zcash_deserialize(&block_bytes[..])

View File

@ -16,7 +16,7 @@ const BLOCK_HEADER_LENGTH: usize = EQUIHASH_SOLUTION_BLOCK_OFFSET + 3 + equihash
#[test]
fn equihash_solution_test_vectors() {
zebra_test::init();
let _init_guard = zebra_test::init();
for block in zebra_test::vectors::BLOCKS.iter() {
let solution_bytes = &block[EQUIHASH_SOLUTION_BLOCK_OFFSET..BLOCK_HEADER_LENGTH];
@ -37,7 +37,7 @@ fn equihash_solution_test_vectors() {
#[test]
fn equihash_solution_test_vectors_are_valid() -> color_eyre::eyre::Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
for block in zebra_test::vectors::BLOCKS.iter() {
let block =
@ -61,7 +61,7 @@ static EQUIHASH_SIZE_TESTS: &[usize] = &[
#[test]
fn equihash_solution_size_field() {
zebra_test::init();
let _init_guard = zebra_test::init();
for size in EQUIHASH_SIZE_TESTS.iter().copied() {
let mut data = Vec::new();

View File

@ -5,7 +5,7 @@ use std::convert::TryFrom;
#[test]
// Check funding streams are correct in the entire period.
fn test_funding_stream_values() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let network = Network::Mainnet;
// funding streams not active

View File

@ -85,7 +85,7 @@ mod test {
#[test]
fn halving_test() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
halving_for_network(Network::Mainnet)?;
halving_for_network(Network::Testnet)?;
@ -172,7 +172,7 @@ mod test {
#[test]
fn block_subsidy_test() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
block_subsidy_for_network(Network::Mainnet)?;
block_subsidy_for_network(Network::Testnet)?;

View File

@ -122,7 +122,7 @@ async fn check_transcripts_test() -> Result<(), Report> {
#[allow(dead_code)]
#[spandoc::spandoc]
async fn check_transcripts() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let network = Network::Mainnet;
let state_service = zebra_state::init_test(network);
@ -148,7 +148,7 @@ async fn check_transcripts() -> Result<(), Report> {
#[test]
fn coinbase_is_first_for_historical_blocks() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block_iter = zebra_test::vectors::BLOCKS.iter();
@ -166,7 +166,7 @@ fn coinbase_is_first_for_historical_blocks() -> Result<(), Report> {
#[test]
fn difficulty_is_valid_for_historical_blocks() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
difficulty_is_valid_for_network(Network::Mainnet)?;
difficulty_is_valid_for_network(Network::Testnet)?;
@ -194,7 +194,7 @@ fn difficulty_is_valid_for_network(network: Network) -> Result<(), Report> {
#[test]
fn difficulty_validation_failure() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Get a block in the mainnet, and mangle its difficulty field
let block =
@ -255,7 +255,7 @@ fn difficulty_validation_failure() -> Result<(), Report> {
#[test]
fn equihash_is_valid_for_historical_blocks() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block_iter = zebra_test::vectors::BLOCKS.iter();
@ -273,7 +273,7 @@ fn equihash_is_valid_for_historical_blocks() -> Result<(), Report> {
#[test]
fn subsidy_is_valid_for_historical_blocks() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
subsidy_is_valid_for_network(Network::Mainnet)?;
subsidy_is_valid_for_network(Network::Testnet)?;
@ -307,7 +307,7 @@ fn subsidy_is_valid_for_network(network: Network) -> Result<(), Report> {
#[test]
fn coinbase_validation_failure() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let network = Network::Mainnet;
// Get a block in the mainnet that is inside the funding stream period,
@ -378,7 +378,7 @@ fn coinbase_validation_failure() -> Result<(), Report> {
#[test]
fn funding_stream_validation() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
funding_stream_validation_for_network(Network::Mainnet)?;
funding_stream_validation_for_network(Network::Testnet)?;
@ -411,7 +411,7 @@ fn funding_stream_validation_for_network(network: Network) -> Result<(), Report>
#[test]
fn funding_stream_validation_failure() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let network = Network::Mainnet;
// Get a block in the mainnet that is inside the funding stream period.
@ -456,7 +456,7 @@ fn funding_stream_validation_failure() -> Result<(), Report> {
#[test]
fn miner_fees_validation_success() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
miner_fees_validation_for_network(Network::Mainnet)?;
miner_fees_validation_for_network(Network::Testnet)?;
@ -488,7 +488,7 @@ fn miner_fees_validation_for_network(network: Network) -> Result<(), Report> {
#[test]
fn miner_fees_validation_failure() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let network = Network::Mainnet;
let block =
@ -511,7 +511,7 @@ fn miner_fees_validation_failure() -> Result<(), Report> {
#[test]
fn time_is_valid_for_historical_blocks() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block_iter = zebra_test::vectors::BLOCKS.iter();
let now = Utc::now();
@ -540,7 +540,7 @@ fn time_is_valid_for_historical_blocks() -> Result<(), Report> {
#[test]
fn merkle_root_is_valid() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
// test all original blocks available, all blocks validate
merkle_root_is_valid_for_network(Network::Mainnet)?;
@ -629,7 +629,7 @@ fn merkle_root_fake_v5_for_network(network: Network) -> Result<(), Report> {
#[test]
fn legacy_sigops_count_for_large_generated_blocks() {
zebra_test::init();
let _init_guard = zebra_test::init();
// We can't test sigops using the transaction verifier, because it looks up UTXOs.
@ -660,7 +660,7 @@ fn legacy_sigops_count_for_large_generated_blocks() {
#[test]
fn legacy_sigops_count_for_historic_blocks() {
zebra_test::init();
let _init_guard = zebra_test::init();
// We can't test sigops using the transaction verifier, because it looks up UTXOs.
@ -684,7 +684,7 @@ fn legacy_sigops_count_for_historic_blocks() {
#[test]
fn transaction_expiration_height_validation() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
transaction_expiration_height_for_network(Network::Mainnet)?;
transaction_expiration_height_for_network(Network::Testnet)?;

View File

@ -155,7 +155,7 @@ async fn verify_checkpoint_test() -> Result<(), Report> {
/// Also tests the `chain::init` function.
#[spandoc::spandoc]
async fn verify_checkpoint(config: Config) -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let network = Network::Mainnet;
@ -187,7 +187,7 @@ async fn verify_fail_no_coinbase_test() -> Result<(), Report> {
/// and BlockVerifier. This is the error case, where there is no height.
#[spandoc::spandoc]
async fn verify_fail_no_coinbase() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let (chain_verifier, state_service) = verifiers_from_network(Network::Mainnet).await;
@ -212,7 +212,7 @@ async fn round_trip_checkpoint_test() -> Result<(), Report> {
/// Test that state updates work
#[spandoc::spandoc]
async fn round_trip_checkpoint() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let (chain_verifier, state_service) = verifiers_from_network(Network::Mainnet).await;
@ -237,7 +237,7 @@ async fn verify_fail_add_block_checkpoint_test() -> Result<(), Report> {
/// Test that the state rejects duplicate block adds
#[spandoc::spandoc]
async fn verify_fail_add_block_checkpoint() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let (chain_verifier, state_service) = verifiers_from_network(Network::Mainnet).await;

View File

@ -13,7 +13,7 @@ use zebra_chain::{
/// Make a checkpoint list containing only the genesis block
#[test]
fn checkpoint_list_genesis() -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Parse the genesis block
let mut checkpoint_data = Vec::new();
@ -36,7 +36,7 @@ fn checkpoint_list_genesis() -> Result<(), BoxError> {
/// Make a checkpoint list containing multiple blocks
#[test]
fn checkpoint_list_multiple() -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Parse all the blocks
let mut checkpoint_data = Vec::new();
@ -65,7 +65,7 @@ fn checkpoint_list_multiple() -> Result<(), BoxError> {
/// Make sure that an empty checkpoint list fails
#[test]
fn checkpoint_list_empty_fail() -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
let _ = CheckpointList::from_list(Vec::new()).expect_err("empty checkpoint lists should fail");
@ -75,7 +75,7 @@ fn checkpoint_list_empty_fail() -> Result<(), BoxError> {
/// Make sure a checkpoint list that doesn't contain the genesis block fails
#[test]
fn checkpoint_list_no_genesis_fail() -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Parse a non-genesis block
let mut checkpoint_data = Vec::new();
@ -98,7 +98,7 @@ fn checkpoint_list_no_genesis_fail() -> Result<(), BoxError> {
/// Make sure a checkpoint list that contains a null hash fails
#[test]
fn checkpoint_list_null_hash_fail() -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
let checkpoint_data = vec![(block::Height(0), block::Hash([0; 32]))];
@ -114,7 +114,7 @@ fn checkpoint_list_null_hash_fail() -> Result<(), BoxError> {
/// Make sure a checkpoint list that contains an invalid block height fails
#[test]
fn checkpoint_list_bad_height_fail() -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
let checkpoint_data = vec![(
block::Height(block::Height::MAX.0 + 1),
@ -142,7 +142,7 @@ fn checkpoint_list_bad_height_fail() -> Result<(), BoxError> {
/// Make sure that a checkpoint list containing duplicate blocks fails
#[test]
fn checkpoint_list_duplicate_blocks_fail() -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Parse some blocks twice
let mut checkpoint_data = Vec::new();
@ -170,7 +170,7 @@ fn checkpoint_list_duplicate_blocks_fail() -> Result<(), BoxError> {
/// (with different hashes) fails
#[test]
fn checkpoint_list_duplicate_heights_fail() -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Parse the genesis block
let mut checkpoint_data = Vec::new();
@ -197,7 +197,7 @@ fn checkpoint_list_duplicate_heights_fail() -> Result<(), BoxError> {
/// (at different heights) fails
#[test]
fn checkpoint_list_duplicate_hashes_fail() -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Parse the genesis block
let mut checkpoint_data = Vec::new();
@ -223,7 +223,7 @@ fn checkpoint_list_duplicate_hashes_fail() -> Result<(), BoxError> {
/// Parse and check the hard-coded Mainnet and Testnet lists
#[test]
fn checkpoint_list_load_hard_coded() -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
let _: CheckpointList = MAINNET_CHECKPOINTS
.parse()
@ -250,7 +250,7 @@ fn checkpoint_list_hard_coded_mandatory_testnet() -> Result<(), BoxError> {
/// Check that the hard-coded lists cover the mandatory checkpoint
fn checkpoint_list_hard_coded_mandatory(network: Network) -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
let mandatory_checkpoint = network.mandatory_checkpoint_height();
@ -280,7 +280,7 @@ fn checkpoint_list_hard_coded_max_gap_testnet() -> Result<(), BoxError> {
/// blockchain in the tests. But that's ok, because the byte limit only impacts
/// performance.
fn checkpoint_list_hard_coded_max_gap(network: Network) -> Result<(), BoxError> {
zebra_test::init();
let _init_guard = zebra_test::init();
let list = CheckpointList::new(network);
let mut heights = list.0.keys();

View File

@ -36,7 +36,7 @@ async fn single_item_checkpoint_list_test() -> Result<(), Report> {
#[spandoc::spandoc]
async fn single_item_checkpoint_list() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block0 =
Arc::<Block>::zcash_deserialize(&zebra_test::vectors::BLOCK_MAINNET_GENESIS_BYTES[..])?;
@ -107,7 +107,7 @@ async fn multi_item_checkpoint_list_test() -> Result<(), Report> {
#[spandoc::spandoc]
async fn multi_item_checkpoint_list() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Parse all the blocks
let mut checkpoint_data = Vec::new();
@ -231,7 +231,7 @@ async fn continuous_blockchain(
restart_height: Option<block::Height>,
network: Network,
) -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
// A continuous blockchain
let blockchain = match network {
@ -431,7 +431,7 @@ async fn block_higher_than_max_checkpoint_fail_test() -> Result<(), Report> {
#[spandoc::spandoc]
async fn block_higher_than_max_checkpoint_fail() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block0 =
Arc::<Block>::zcash_deserialize(&zebra_test::vectors::BLOCK_MAINNET_GENESIS_BYTES[..])?;
@ -501,7 +501,7 @@ async fn wrong_checkpoint_hash_fail_test() -> Result<(), Report> {
#[spandoc::spandoc]
async fn wrong_checkpoint_hash_fail() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let good_block0 =
Arc::<Block>::zcash_deserialize(&zebra_test::vectors::BLOCK_MAINNET_GENESIS_BYTES[..])?;
@ -669,7 +669,7 @@ async fn checkpoint_drop_cancel_test() -> Result<(), Report> {
#[spandoc::spandoc]
async fn checkpoint_drop_cancel() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Parse all the blocks
let mut checkpoint_data = Vec::new();
@ -769,7 +769,7 @@ async fn hard_coded_mainnet_test() -> Result<(), Report> {
#[spandoc::spandoc]
async fn hard_coded_mainnet() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block0 =
Arc::<Block>::zcash_deserialize(&zebra_test::vectors::BLOCK_MAINNET_GENESIS_BYTES[..])?;

View File

@ -27,7 +27,7 @@ where
std::boxed::Box<dyn std::error::Error + std::marker::Send + std::marker::Sync>,
>,
{
zebra_test::init();
let _init_guard = zebra_test::init();
let mut async_checks = FuturesUnordered::new();
@ -138,7 +138,7 @@ where
std::boxed::Box<dyn std::error::Error + std::marker::Send + std::marker::Sync>,
>,
{
zebra_test::init();
let _init_guard = zebra_test::init();
let mut async_checks = FuturesUnordered::new();
@ -219,7 +219,7 @@ where
std::boxed::Box<dyn std::error::Error + std::marker::Send + std::marker::Sync>,
>,
{
zebra_test::init();
let _init_guard = zebra_test::init();
let mut async_checks = FuturesUnordered::new();
@ -291,7 +291,7 @@ where
std::boxed::Box<dyn std::error::Error + std::marker::Send + std::marker::Sync>,
>,
{
zebra_test::init();
let _init_guard = zebra_test::init();
let mut async_checks = FuturesUnordered::new();
@ -407,7 +407,7 @@ where
std::boxed::Box<dyn std::error::Error + std::marker::Send + std::marker::Sync>,
>,
{
zebra_test::init();
let _init_guard = zebra_test::init();
let mut async_checks = FuturesUnordered::new();

View File

@ -132,7 +132,7 @@ where
#[tokio::test(flavor = "multi_thread")]
async fn verify_generated_halo2_proofs() {
zebra_test::init();
let _init_guard = zebra_test::init();
// These test vectors are generated by `generate_test_vectors()` function.
let shielded_data = zebra_test::vectors::ORCHARD_SHIELDED_DATA
@ -199,7 +199,7 @@ where
#[tokio::test(flavor = "multi_thread")]
async fn correctly_err_on_invalid_halo2_proofs() {
zebra_test::init();
let _init_guard = zebra_test::init();
// These test vectors are generated by `generate_test_vectors()` function.
let shielded_data = zebra_test::vectors::ORCHARD_SHIELDED_DATA

View File

@ -37,7 +37,7 @@ mod prop;
#[test]
fn v5_fake_transactions() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let networks = vec![
(Network::Mainnet, zebra_test::vectors::MAINNET_BLOCKS.iter()),
@ -289,7 +289,7 @@ fn v5_transaction_is_accepted_after_nu5_activation_testnet() {
}
fn v5_transaction_is_accepted_after_nu5_activation_for_network(network: Network) {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
let nu5 = NetworkUpgrade::Nu5;
let nu5_activation_height = nu5
@ -769,7 +769,7 @@ async fn v4_transaction_with_conflicting_transparent_spend_is_rejected() {
/// Test if V4 transaction with a joinsplit that has duplicate nullifiers is rejected.
#[test]
fn v4_transaction_with_conflicting_sprout_nullifier_inside_joinsplit_is_rejected() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
let network = Network::Mainnet;
let network_upgrade = NetworkUpgrade::Canopy;
@ -834,7 +834,7 @@ fn v4_transaction_with_conflicting_sprout_nullifier_inside_joinsplit_is_rejected
/// Test if V4 transaction with duplicate nullifiers across joinsplits is rejected.
#[test]
fn v4_transaction_with_conflicting_sprout_nullifier_across_joinsplits_is_rejected() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
let network = Network::Mainnet;
let network_upgrade = NetworkUpgrade::Canopy;
@ -1364,7 +1364,7 @@ async fn v5_transaction_with_conflicting_transparent_spend_is_rejected() {
/// This test verifies if the transaction verifier correctly accepts a signed transaction.
#[test]
fn v4_with_signed_sprout_transfer_is_accepted() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
let network = Network::Mainnet;
@ -1407,7 +1407,7 @@ fn v4_with_signed_sprout_transfer_is_accepted() {
/// invalid JoinSplit.
#[test]
fn v4_with_modified_joinsplit_is_rejected() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
v4_with_joinsplit_is_rejected_for_modification(
JoinSplitModification::CorruptSignature,
@ -1473,7 +1473,7 @@ async fn v4_with_joinsplit_is_rejected_for_modification(
/// Test if a V4 transaction with Sapling spends is accepted by the verifier.
#[test]
fn v4_with_sapling_spends() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
let network = Network::Mainnet;
@ -1513,7 +1513,7 @@ fn v4_with_sapling_spends() {
/// Test if a V4 transaction with a duplicate Sapling spend is rejected by the verifier.
#[test]
fn v4_with_duplicate_sapling_spends() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
let network = Network::Mainnet;
@ -1558,7 +1558,7 @@ fn v4_with_duplicate_sapling_spends() {
/// Test if a V4 transaction with Sapling outputs but no spends is accepted by the verifier.
#[test]
fn v4_with_sapling_outputs_and_no_spends() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
let network = Network::Mainnet;
@ -1603,7 +1603,7 @@ fn v4_with_sapling_outputs_and_no_spends() {
// TODO: add NU5 mainnet test vectors with Sapling spends, then remove should_panic
#[should_panic]
fn v5_with_sapling_spends() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
let network = Network::Mainnet;
let nu5_activation = NetworkUpgrade::Nu5.activation_height(network);
@ -1650,7 +1650,7 @@ fn v5_with_sapling_spends() {
/// Test if a V5 transaction with a duplicate Sapling spend is rejected by the verifier.
#[test]
fn v5_with_duplicate_sapling_spends() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
let network = Network::Mainnet;
@ -1696,7 +1696,7 @@ fn v5_with_duplicate_sapling_spends() {
/// Test if a V5 transaction with a duplicate Orchard action is rejected by the verifier.
#[test]
fn v5_with_duplicate_orchard_action() {
zebra_test::init();
let _init_guard = zebra_test::init();
zebra_test::MULTI_THREADED_RUNTIME.block_on(async {
let network = Network::Mainnet;
@ -2018,7 +2018,7 @@ fn duplicate_sapling_spend_in_shielded_data<A: sapling::AnchorVariant + Clone>(
#[test]
fn add_to_sprout_pool_after_nu() {
zebra_test::init();
let _init_guard = zebra_test::init();
// get a block that we know it haves a transaction with `vpub_old` field greater than 0.
let block: Arc<_> = zebra_chain::block::Block::zcash_deserialize(
@ -2076,7 +2076,7 @@ fn add_to_sprout_pool_after_nu() {
#[test]
fn coinbase_outputs_are_decryptable_for_historical_blocks() -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
coinbase_outputs_are_decryptable_for_historical_blocks_for_network(Network::Mainnet)?;
coinbase_outputs_are_decryptable_for_historical_blocks_for_network(Network::Testnet)?;

View File

@ -29,7 +29,7 @@ proptest! {
relative_source_fund_heights in vec(0.0..1.0, 1..=MAX_TRANSPARENT_INPUTS),
transaction_version in 4_u8..=5,
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let zero_lock_time = LockTime::Height(block::Height(0));
@ -62,7 +62,7 @@ proptest! {
transaction_version in 4_u8..=5,
lock_time in any::<LockTime>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut transaction, known_utxos) = mock_transparent_transaction(
network,
@ -97,7 +97,7 @@ proptest! {
transaction_version in 4_u8..=5,
relative_unlock_height in 0.0..1.0,
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let unlock_height = scale_block_height(block_height, None, relative_unlock_height);
let lock_time = LockTime::Height(unlock_height);
@ -127,7 +127,7 @@ proptest! {
relative_source_fund_heights in vec(0.0..1.0, 1..=MAX_TRANSPARENT_INPUTS),
transaction_version in 4_u8..=5,
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let (unlock_time, block_time) = if first_datetime >= second_datetime {
(first_datetime, second_datetime)
@ -160,7 +160,7 @@ proptest! {
transaction_version in 4_u8..=5,
relative_unlock_height in 0.0..1.0,
) {
zebra_test::init();
let _init_guard = zebra_test::init();
// Because `scale_block_height` uses the range `[min, max)`, with `max` being
// non-inclusive, we have to use `block_height + 1` as the upper bound in order to test
@ -198,7 +198,7 @@ proptest! {
relative_source_fund_heights in vec(0.0..1.0, 1..=MAX_TRANSPARENT_INPUTS),
transaction_version in 4_u8..=5,
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let (unlock_time, block_time) = if first_datetime < second_datetime {
(first_datetime, second_datetime)

View File

@ -24,7 +24,7 @@ proptest! {
local_listener in any::<SocketAddr>(),
addresses in vec(any::<MetaAddr>(), 0..MAX_META_ADDR),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let chrono_now = Utc::now();
let address_book = AddressBook::new_with_addrs(
@ -52,7 +52,7 @@ proptest! {
local_listener in any::<SocketAddr>(),
addresses in vec(any::<MetaAddr>(), 0..MAX_META_ADDR),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let instant_now = Instant::now();
let chrono_now = Utc::now();
@ -80,7 +80,7 @@ proptest! {
addr_limit in 0..=MAX_ADDR_CHANGE,
pre_fill in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let initial_addrs = if pre_fill {
addr_changes_lists

View File

@ -9,7 +9,7 @@ use crate::{
#[test]
fn parse_config_listen_addr() {
zebra_test::init();
let _init_guard = zebra_test::init();
let fixtures = vec![
("listen_addr = '0.0.0.0'", "0.0.0.0:8233"),
@ -33,7 +33,7 @@ fn parse_config_listen_addr() {
/// Make sure the peer connection limits are consistent with each other.
#[test]
fn ensure_peer_connection_limits_consistent() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Zebra should allow more inbound connections, to avoid connection exhaustion
const_assert!(INBOUND_PEER_LIMIT_MULTIPLIER > OUTBOUND_PEER_LIMIT_MULTIPLIER);

View File

@ -336,7 +336,7 @@ mod tests {
/// it relies on.
#[test]
fn ensure_live_peer_duration_value_matches_others() {
zebra_test::init();
let _init_guard = zebra_test::init();
let constructed_live_peer_duration =
HEARTBEAT_INTERVAL + REQUEST_TIMEOUT + REQUEST_TIMEOUT + REQUEST_TIMEOUT;
@ -347,7 +347,7 @@ mod tests {
/// Make sure that the timeout values are consistent with each other.
#[test]
fn ensure_timeouts_consistent() {
zebra_test::init();
let _init_guard = zebra_test::init();
assert!(HANDSHAKE_TIMEOUT <= REQUEST_TIMEOUT,
"Handshakes are requests, so the handshake timeout can't be longer than the timeout for all requests.");
@ -382,7 +382,7 @@ mod tests {
/// Make sure that peer age limits are consistent with each other.
#[test]
fn ensure_peer_age_limits_consistent() {
zebra_test::init();
let _init_guard = zebra_test::init();
assert!(
MAX_PEER_ACTIVE_FOR_GOSSIP <= MAX_RECENT_PEER_AGE,
@ -397,7 +397,7 @@ mod tests {
// Zebra 1.0.0-beta.2 address book metrics in December 2021.
const TYPICAL_MAINNET_ADDRESS_BOOK_SIZE: usize = 4_500;
zebra_test::init();
let _init_guard = zebra_test::init();
assert!(
MAX_ADDRS_IN_ADDRESS_BOOK >= GET_ADDR_FANOUT * MAX_ADDRS_IN_MESSAGE,
@ -418,7 +418,7 @@ mod tests {
/// Make sure inventory registry rotation is consistent with the target block interval.
#[test]
fn ensure_inventory_rotation_consistent() {
zebra_test::init();
let _init_guard = zebra_test::init();
assert!(
INVENTORY_ROTATION_INTERVAL

View File

@ -19,7 +19,7 @@ use Network::*;
/// when sent over TCP.
#[tokio::test]
async fn connect_isolated_sends_anonymised_version_message_tcp() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;
@ -78,7 +78,7 @@ async fn connect_isolated_sends_anonymised_version_message_tcp_net(network: Netw
/// - runs even if network tests are disabled.
#[tokio::test]
async fn connect_isolated_sends_anonymised_version_message_mem() {
zebra_test::init();
let _init_guard = zebra_test::init();
connect_isolated_sends_anonymised_version_message_mem_net(Mainnet).await;
connect_isolated_sends_anonymised_version_message_mem_net(Testnet).await;

View File

@ -18,7 +18,7 @@ const MAX_TEST_DURATION: Duration = Duration::from_secs(20);
/// (We can't connect to ourselves over Tor, so there's not much more we can do here.)
#[tokio::test]
async fn connect_isolated_run_tor_once() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;
@ -43,7 +43,7 @@ async fn connect_isolated_run_tor_once() {
/// Use the multi-threaded runtime to test concurrent Tor instances.
#[tokio::test(flavor = "multi_thread")]
async fn connect_isolated_run_tor_multi() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;

View File

@ -41,7 +41,7 @@ proptest! {
/// and client services.
#[test]
fn sanitize_avoids_leaks(addr in MetaAddr::arbitrary()) {
zebra_test::init();
let _init_guard = zebra_test::init();
if let Some(sanitized) = addr.sanitize(Mainnet) {
// check that all sanitized addresses are valid for outbound
@ -65,7 +65,7 @@ proptest! {
fn preserve_initial_untrusted_values(
(mut addr, changes) in MetaAddrChange::addr_changes_strategy(MAX_ADDR_CHANGE),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
for change in changes {
if let Some(changed_addr) = change.apply_to_meta_addr(addr) {
@ -106,7 +106,7 @@ proptest! {
fn individual_peer_retry_limit_meta_addr(
(mut addr, changes) in MetaAddrChange::addr_changes_strategy(MAX_ADDR_CHANGE)
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let instant_now = std::time::Instant::now();
let chrono_now = Utc::now();
@ -145,7 +145,7 @@ proptest! {
local_listener in any::<SocketAddr>(),
address_book_addrs in vec(any::<MetaAddr>(), 0..MAX_META_ADDR),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let chrono_now = Utc::now();
@ -185,7 +185,7 @@ proptest! {
fn new_meta_addr_from_meta_addr_change(
(addr, changes) in MetaAddrChange::addr_changes_strategy(MAX_ADDR_CHANGE)
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let local_listener = "0.0.0.0:0".parse().expect("unexpected invalid SocketAddr");
@ -293,7 +293,7 @@ proptest! {
fn individual_peer_retry_limit_candidate_set(
(addr, changes) in MetaAddrChange::addr_changes_strategy(MAX_ADDR_CHANGE)
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// Run the test for this many simulated live peer durations
@ -392,7 +392,7 @@ proptest! {
2..MAX_ADDR_CHANGE
),
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
let instant_now = std::time::Instant::now();

View File

@ -22,7 +22,7 @@ const TEST_TIME_ERROR_MARGIN: Duration32 = Duration32::from_seconds(1);
/// Make sure that the sanitize function handles minimum and maximum times.
#[test]
fn sanitize_extremes() {
zebra_test::init();
let _init_guard = zebra_test::init();
let min_time_entry = MetaAddr {
addr: "127.0.0.1:8233".parse().unwrap(),
@ -57,7 +57,7 @@ fn sanitize_extremes() {
/// The local listener [`MetaAddr`] is always considered gossipable.
#[test]
fn new_local_listener_is_gossipable() {
zebra_test::init();
let _init_guard = zebra_test::init();
let chrono_now = Utc::now();
@ -75,7 +75,7 @@ fn new_local_listener_is_gossipable() {
/// confirmed that the address is reachable.
#[test]
fn new_alternate_peer_address_is_not_gossipable() {
zebra_test::init();
let _init_guard = zebra_test::init();
let chrono_now = Utc::now();
@ -90,7 +90,7 @@ fn new_alternate_peer_address_is_not_gossipable() {
/// Test if recently received gossiped peer is gossipable.
#[test]
fn gossiped_peer_reportedly_to_be_seen_recently_is_gossipable() {
zebra_test::init();
let _init_guard = zebra_test::init();
let chrono_now = Utc::now();
@ -112,7 +112,7 @@ fn gossiped_peer_reportedly_to_be_seen_recently_is_gossipable() {
/// Test if received gossiped peer that was reportedly last seen in the future is gossipable.
#[test]
fn gossiped_peer_reportedly_seen_in_the_future_is_gossipable() {
zebra_test::init();
let _init_guard = zebra_test::init();
let chrono_now = Utc::now();
@ -131,7 +131,7 @@ fn gossiped_peer_reportedly_seen_in_the_future_is_gossipable() {
/// Test if gossiped peer that was reported last seen a long time ago is not gossipable.
#[test]
fn gossiped_peer_reportedly_seen_long_ago_is_not_gossipable() {
zebra_test::init();
let _init_guard = zebra_test::init();
let chrono_now = Utc::now();
@ -153,7 +153,7 @@ fn gossiped_peer_reportedly_seen_long_ago_is_not_gossipable() {
/// Test that peer that has just responded is gossipable.
#[test]
fn recently_responded_peer_is_gossipable() {
zebra_test::init();
let _init_guard = zebra_test::init();
let chrono_now = Utc::now();
@ -173,7 +173,7 @@ fn recently_responded_peer_is_gossipable() {
/// Test that peer that last responded in the reachable interval is gossipable.
#[test]
fn not_so_recently_responded_peer_is_still_gossipable() {
zebra_test::init();
let _init_guard = zebra_test::init();
let chrono_now = Utc::now();
@ -203,7 +203,7 @@ fn not_so_recently_responded_peer_is_still_gossipable() {
/// Test that peer that responded long ago is not gossipable.
#[test]
fn responded_long_ago_peer_is_not_gossipable() {
zebra_test::init();
let _init_guard = zebra_test::init();
let chrono_now = Utc::now();

View File

@ -18,7 +18,7 @@ use crate::{
/// Test that a newly initialized client functions correctly before it is polled.
#[tokio::test]
async fn client_service_ok_without_readiness_check() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (_client, mut harness) = ClientTestHarness::build().finish();
@ -30,7 +30,7 @@ async fn client_service_ok_without_readiness_check() {
/// Test that a newly initialized client functions correctly after it is polled.
#[tokio::test]
async fn client_service_ready_ok() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, mut harness) = ClientTestHarness::build().finish();
@ -43,7 +43,7 @@ async fn client_service_ready_ok() {
/// Test that a client functions correctly if its readiness future is dropped.
#[tokio::test]
async fn client_service_ready_drop_ok() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, mut harness) = ClientTestHarness::build().finish();
@ -61,7 +61,7 @@ async fn client_service_ready_drop_ok() {
/// Test that a client functions correctly if it is polled for readiness multiple times.
#[tokio::test]
async fn client_service_ready_multiple_ok() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, mut harness) = ClientTestHarness::build().finish();
@ -76,7 +76,7 @@ async fn client_service_ready_multiple_ok() {
/// Test that clients propagate errors from their heartbeat tasks.
#[tokio::test]
async fn client_service_ready_heartbeat_exit() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, mut harness) = ClientTestHarness::build().finish();
@ -91,7 +91,7 @@ async fn client_service_ready_heartbeat_exit() {
/// Test that clients propagate errors from their connection tasks.
#[tokio::test]
async fn client_service_ready_request_drop() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, mut harness) = ClientTestHarness::build().finish();
@ -106,7 +106,7 @@ async fn client_service_ready_request_drop() {
/// Test that clients error when their connection task closes the request channel.
#[tokio::test]
async fn client_service_ready_request_close() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, mut harness) = ClientTestHarness::build().finish();
@ -121,7 +121,7 @@ async fn client_service_ready_request_close() {
#[tokio::test]
async fn client_service_ready_error_in_slot() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, mut harness) = ClientTestHarness::build().finish();
@ -136,7 +136,7 @@ async fn client_service_ready_error_in_slot() {
/// Test that clients error when multiple error conditions occur at the same time.
#[tokio::test]
async fn client_service_ready_multiple_errors() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, mut harness) = ClientTestHarness::build().finish();
@ -152,7 +152,7 @@ async fn client_service_ready_multiple_errors() {
/// Test that clients register an error and cleanup channels correctly when the client is dropped.
#[tokio::test]
async fn client_service_drop_cleanup() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (client, mut harness) = ClientTestHarness::build().finish();
@ -166,7 +166,7 @@ async fn client_service_drop_cleanup() {
/// Force the connection background task to stop, and check if the `Client` properly handles it.
#[tokio::test]
async fn client_service_handles_exited_connection_task() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, mut harness) = ClientTestHarness::build().finish();
@ -182,7 +182,7 @@ async fn client_service_handles_exited_connection_task() {
#[tokio::test]
#[should_panic]
async fn client_service_propagates_panic_from_connection_task() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, _harness) = ClientTestHarness::build()
.with_connection_task(async move {
@ -199,7 +199,7 @@ async fn client_service_propagates_panic_from_connection_task() {
/// Force the heartbeat background task to stop, and check if the `Client` properly handles it.
#[tokio::test]
async fn client_service_handles_exited_heartbeat_task() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, mut harness) = ClientTestHarness::build().finish();
@ -215,7 +215,7 @@ async fn client_service_handles_exited_heartbeat_task() {
#[tokio::test]
#[should_panic]
async fn client_service_propagates_panic_from_heartbeat_task() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut client, _harness) = ClientTestHarness::build()
.with_heartbeat_task(async move {
@ -238,7 +238,7 @@ async fn client_service_propagates_panic_from_heartbeat_task() {
/// and we would never ask the peer if it has received the inventory.
#[test]
fn missing_inv_collector_ignores_local_registry_errors() {
zebra_test::init();
let _init_guard = zebra_test::init();
let block_hash = block::Hash([0; 32]);
let request = Request::BlocksByHash(iter::once(block_hash).collect());

View File

@ -45,7 +45,7 @@ proptest! {
first_block in any::<DisplayToDebug<Arc<Block>>>(),
second_block in any::<DisplayToDebug<Arc<Block>>>(),
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
runtime.block_on(async move {
// The real stream and sink are from a split TCP connection,

View File

@ -29,7 +29,7 @@ use crate::{
/// Test that the connection run loop works as a future
#[tokio::test]
async fn connection_run_loop_ok() {
zebra_test::init();
let _init_guard = zebra_test::init();
// The real stream and sink are from a split TCP connection,
// but that doesn't change how the state machine behaves.
@ -66,7 +66,7 @@ async fn connection_run_loop_ok() {
/// Test that the connection run loop works as a spawned task
#[tokio::test]
async fn connection_run_loop_spawn_ok() {
zebra_test::init();
let _init_guard = zebra_test::init();
// The real stream and sink are from a split TCP connection,
// but that doesn't change how the state machine behaves.
@ -108,7 +108,7 @@ async fn connection_run_loop_spawn_ok() {
/// Test that the connection run loop works as a spawned task with messages in and out
#[tokio::test]
async fn connection_run_loop_message_ok() {
zebra_test::init();
let _init_guard = zebra_test::init();
tokio::time::pause();
@ -188,7 +188,7 @@ async fn connection_run_loop_message_ok() {
/// Test that the connection run loop fails correctly when dropped
#[tokio::test]
async fn connection_run_loop_future_drop() {
zebra_test::init();
let _init_guard = zebra_test::init();
// The real stream and sink are from a split TCP connection,
// but that doesn't change how the state machine behaves.
@ -221,7 +221,7 @@ async fn connection_run_loop_future_drop() {
/// Test that the connection run loop fails correctly when the internal client closes the connection channel
#[tokio::test]
async fn connection_run_loop_client_close() {
zebra_test::init();
let _init_guard = zebra_test::init();
// The real stream and sink are from a split TCP connection,
// but that doesn't change how the state machine behaves.
@ -266,7 +266,7 @@ async fn connection_run_loop_client_close() {
/// Test that the connection run loop fails correctly when the internal client drops the connection channel
#[tokio::test]
async fn connection_run_loop_client_drop() {
zebra_test::init();
let _init_guard = zebra_test::init();
// The real stream and sink are from a split TCP connection,
// but that doesn't change how the state machine behaves.
@ -306,7 +306,7 @@ async fn connection_run_loop_client_drop() {
/// (We're not sure if tokio closes or drops the TcpStream when the TCP connection closes.)
#[tokio::test]
async fn connection_run_loop_inbound_close() {
zebra_test::init();
let _init_guard = zebra_test::init();
// The real stream and sink are from a split TCP connection,
// but that doesn't change how the state machine behaves.
@ -347,7 +347,7 @@ async fn connection_run_loop_inbound_close() {
/// (We're not sure if tokio closes or drops the TcpStream when the TCP connection closes.)
#[tokio::test]
async fn connection_run_loop_inbound_drop() {
zebra_test::init();
let _init_guard = zebra_test::init();
// The real stream and sink are from a split TCP connection,
// but that doesn't change how the state machine behaves.
@ -386,7 +386,7 @@ async fn connection_run_loop_inbound_drop() {
/// Test that the connection run loop fails correctly on internal connection errors.
#[tokio::test]
async fn connection_run_loop_failed() {
zebra_test::init();
let _init_guard = zebra_test::init();
// The real stream and sink are from a split TCP connection,
// but that doesn't change how the state machine behaves.
@ -437,7 +437,7 @@ async fn connection_run_loop_failed() {
/// but we are not expecting a response message from the peer.
#[tokio::test]
async fn connection_run_loop_send_timeout_nil_response() {
zebra_test::init();
let _init_guard = zebra_test::init();
tokio::time::pause();
@ -512,7 +512,7 @@ async fn connection_run_loop_send_timeout_nil_response() {
/// and we are expecting a response message from the peer.
#[tokio::test]
async fn connection_run_loop_send_timeout_expect_response() {
zebra_test::init();
let _init_guard = zebra_test::init();
tokio::time::pause();
@ -587,7 +587,7 @@ async fn connection_run_loop_send_timeout_expect_response() {
/// when a peer accepts a message, but does not send an expected response.
#[tokio::test]
async fn connection_run_loop_receive_timeout() {
zebra_test::init();
let _init_guard = zebra_test::init();
tokio::time::pause();

View File

@ -41,7 +41,7 @@ proptest! {
gossiped_peers in vec(MetaAddr::gossiped_strategy(), 1..TEST_ADDRESSES),
last_seen_limit in any::<DateTime32>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let validated_peers = validate_addrs(gossiped_peers, last_seen_limit);
@ -57,7 +57,7 @@ proptest! {
/// using a "not ready for attempt" peer generation strategy
#[test]
fn skipping_outbound_peer_connection_skips_rate_limit(next_peer_attempts in 0..TEST_ADDRESSES) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
let peer_service = tower::service_fn(|_| async {
@ -96,7 +96,7 @@ proptest! {
initial_candidates in 0..MAX_TEST_CANDIDATES,
extra_candidates in 0..MAX_TEST_CANDIDATES,
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
let peer_service = tower::service_fn(|_| async {

View File

@ -136,7 +136,7 @@ fn candidate_set_updates_are_rate_limited() {
// How many times should `update` be called in each rate limit interval
const POLL_FREQUENCY_FACTOR: u32 = 3;
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
let address_book = AddressBook::new(
@ -181,7 +181,7 @@ fn candidate_set_updates_are_rate_limited() {
/// rate limited.
#[test]
fn candidate_set_update_after_update_initial_is_rate_limited() {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
let address_book = AddressBook::new(

View File

@ -64,7 +64,7 @@ const LISTENER_TEST_DURATION: Duration = Duration::from_secs(10);
/// Note: This test doesn't cover local interface or public IP address discovery.
#[tokio::test]
async fn local_listener_unspecified_port_unspecified_addr_v4() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;
@ -82,7 +82,7 @@ async fn local_listener_unspecified_port_unspecified_addr_v4() {
/// Note: This test doesn't cover local interface or public IP address discovery.
#[tokio::test]
async fn local_listener_unspecified_port_unspecified_addr_v6() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;
@ -101,7 +101,7 @@ async fn local_listener_unspecified_port_unspecified_addr_v6() {
/// and sends them to the `AddressBook`.
#[tokio::test]
async fn local_listener_unspecified_port_localhost_addr_v4() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;
@ -116,7 +116,7 @@ async fn local_listener_unspecified_port_localhost_addr_v4() {
/// and sends them to the `AddressBook`.
#[tokio::test]
async fn local_listener_unspecified_port_localhost_addr_v6() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;
@ -134,7 +134,7 @@ async fn local_listener_unspecified_port_localhost_addr_v6() {
/// Test that zebra-network propagates fixed localhost listener ports to the `AddressBook`.
#[tokio::test]
async fn local_listener_fixed_port_localhost_addr_v4() {
zebra_test::init();
let _init_guard = zebra_test::init();
let localhost_v4 = "127.0.0.1".parse().unwrap();
@ -149,7 +149,7 @@ async fn local_listener_fixed_port_localhost_addr_v4() {
/// Test that zebra-network propagates fixed localhost listener ports to the `AddressBook`.
#[tokio::test]
async fn local_listener_fixed_port_localhost_addr_v6() {
zebra_test::init();
let _init_guard = zebra_test::init();
let localhost_v6 = "::1".parse().unwrap();
@ -170,7 +170,7 @@ async fn local_listener_fixed_port_localhost_addr_v6() {
#[tokio::test]
#[should_panic]
async fn peer_limit_zero_mainnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test should not require network access, because the connection limit is zero.
@ -191,7 +191,7 @@ async fn peer_limit_zero_mainnet() {
#[tokio::test]
#[should_panic]
async fn peer_limit_zero_testnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test should not require network access, because the connection limit is zero.
@ -210,7 +210,7 @@ async fn peer_limit_zero_testnet() {
/// Test zebra-network with a peer limit of one inbound and one outbound peer on mainnet.
#[tokio::test]
async fn peer_limit_one_mainnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;
@ -229,7 +229,7 @@ async fn peer_limit_one_mainnet() {
/// Test zebra-network with a peer limit of one inbound and one outbound peer on testnet.
#[tokio::test]
async fn peer_limit_one_testnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;
@ -248,7 +248,7 @@ async fn peer_limit_one_testnet() {
/// Test zebra-network with a peer limit of two inbound and three outbound peers on mainnet.
#[tokio::test]
async fn peer_limit_two_mainnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;
@ -267,7 +267,7 @@ async fn peer_limit_two_mainnet() {
/// Test zebra-network with a peer limit of two inbound and three outbound peers on testnet.
#[tokio::test]
async fn peer_limit_two_testnet() {
zebra_test::init();
let _init_guard = zebra_test::init();
if zebra_test::net::zebra_skip_network_tests() {
return;
@ -286,7 +286,7 @@ async fn peer_limit_two_testnet() {
/// Test the crawler with an outbound peer limit of zero peers, and a connector that panics.
#[tokio::test]
async fn crawler_peer_limit_zero_connect_panic() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test does not require network access, because the outbound connector
// and peer set are fake.
@ -311,7 +311,7 @@ async fn crawler_peer_limit_zero_connect_panic() {
/// Test the crawler with an outbound peer limit of one peer, and a connector that always errors.
#[tokio::test]
async fn crawler_peer_limit_one_connect_error() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test does not require network access, because the outbound connector
// and peer set are fake.
@ -336,7 +336,7 @@ async fn crawler_peer_limit_one_connect_error() {
/// and a connector that returns success then disconnects the peer.
#[tokio::test]
async fn crawler_peer_limit_one_connect_ok_then_drop() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test does not require network access, because the outbound connector
// and peer set are fake.
@ -397,7 +397,7 @@ async fn crawler_peer_limit_one_connect_ok_then_drop() {
/// and a connector that returns success then holds the peer open.
#[tokio::test]
async fn crawler_peer_limit_one_connect_ok_stay_open() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test does not require network access, because the outbound connector
// and peer set are fake.
@ -486,7 +486,7 @@ async fn crawler_peer_limit_one_connect_ok_stay_open() {
/// Test the crawler with the default outbound peer limit, and a connector that always errors.
#[tokio::test]
async fn crawler_peer_limit_default_connect_error() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test does not require network access, because the outbound connector
// and peer set are fake.
@ -511,7 +511,7 @@ async fn crawler_peer_limit_default_connect_error() {
/// and a connector that returns success then disconnects the peer.
#[tokio::test]
async fn crawler_peer_limit_default_connect_ok_then_drop() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test does not require network access, because the outbound connector
// and peer set are fake.
@ -574,7 +574,7 @@ async fn crawler_peer_limit_default_connect_ok_then_drop() {
/// and a connector that returns success then holds the peer open.
#[tokio::test]
async fn crawler_peer_limit_default_connect_ok_stay_open() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test does not require network access, because the outbound connector
// and peer set are fake.
@ -664,7 +664,7 @@ async fn crawler_peer_limit_default_connect_ok_stay_open() {
/// Test the listener with an inbound peer limit of zero peers, and a handshaker that panics.
#[tokio::test]
async fn listener_peer_limit_zero_handshake_panic() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test requires an IPv4 network stack with 127.0.0.1 as localhost.
if zebra_test::net::zebra_skip_network_tests() {
@ -691,7 +691,7 @@ async fn listener_peer_limit_zero_handshake_panic() {
/// Test the listener with an inbound peer limit of one peer, and a handshaker that always errors.
#[tokio::test]
async fn listener_peer_limit_one_handshake_error() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test requires an IPv4 network stack with 127.0.0.1 as localhost.
if zebra_test::net::zebra_skip_network_tests() {
@ -718,7 +718,7 @@ async fn listener_peer_limit_one_handshake_error() {
/// and a handshaker that returns success then disconnects the peer.
#[tokio::test]
async fn listener_peer_limit_one_handshake_ok_then_drop() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test requires an IPv4 network stack with 127.0.0.1 as localhost.
if zebra_test::net::zebra_skip_network_tests() {
@ -783,7 +783,7 @@ async fn listener_peer_limit_one_handshake_ok_then_drop() {
/// and a handshaker that returns success then holds the peer open.
#[tokio::test]
async fn listener_peer_limit_one_handshake_ok_stay_open() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test requires an IPv4 network stack with 127.0.0.1 as localhost.
if zebra_test::net::zebra_skip_network_tests() {
@ -877,7 +877,7 @@ async fn listener_peer_limit_one_handshake_ok_stay_open() {
/// Test the listener with the default inbound peer limit, and a handshaker that always errors.
#[tokio::test]
async fn listener_peer_limit_default_handshake_error() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test requires an IPv4 network stack with 127.0.0.1 as localhost.
if zebra_test::net::zebra_skip_network_tests() {
@ -908,7 +908,7 @@ async fn listener_peer_limit_default_handshake_error() {
#[cfg(not(target_os = "macos"))]
#[tokio::test]
async fn listener_peer_limit_default_handshake_ok_then_drop() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test requires an IPv4 network stack with 127.0.0.1 as localhost.
if zebra_test::net::zebra_skip_network_tests() {
@ -973,7 +973,7 @@ async fn listener_peer_limit_default_handshake_ok_then_drop() {
/// and a handshaker that returns success then holds the peer open.
#[tokio::test]
async fn listener_peer_limit_default_handshake_ok_stay_open() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test requires an IPv4 network stack with 127.0.0.1 as localhost.
if zebra_test::net::zebra_skip_network_tests() {
@ -1067,7 +1067,7 @@ async fn listener_peer_limit_default_handshake_ok_stay_open() {
/// Test if the initial seed peer connections is rate-limited.
#[tokio::test]
async fn add_initial_peers_is_rate_limited() {
zebra_test::init();
let _init_guard = zebra_test::init();
// This test should not require network access.
@ -1127,7 +1127,7 @@ async fn add_initial_peers_deadlock() {
const PEERSET_INITIAL_TARGET_SIZE: usize = 2;
const TIME_LIMIT: Duration = Duration::from_secs(10);
zebra_test::init();
let _init_guard = zebra_test::init();
// This test requires an IPv4 network stack. Localhost should be enough.
if zebra_test::net::zebra_skip_network_tests() {

View File

@ -28,7 +28,7 @@ proptest! {
prop_assert!(MAX_HASH_COUNT <= MAX_PENDING_CHANGES, "channel must not block in tests");
// Start the runtime
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
runtime.block_on(async move {
// Check all combinations of:

View File

@ -27,7 +27,7 @@ proptest! {
block_height in any::<block::Height>(),
peer_versions in any::<PeerVersions>(),
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let (mut minimum_peer_version, best_tip_height) =
MinimumPeerVersion::with_mock_chain_tip(network);
@ -59,7 +59,7 @@ proptest! {
block_heights in any::<BlockHeightPairAcrossNetworkUpgrades>(),
peer_versions in any::<PeerVersions>(),
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let (mut minimum_peer_version, best_tip_height) =
MinimumPeerVersion::with_mock_chain_tip(block_heights.network);
@ -103,7 +103,7 @@ proptest! {
let block_hash = block::Hash::from(&block);
// Start the runtime
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
let peer_versions = vec![CURRENT_NETWORK_PROTOCOL_VERSION; total_number_of_peers];
@ -176,7 +176,7 @@ proptest! {
let block_hash = block::Hash::from(&block);
// Start the runtime
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// All peers will have the current version
@ -245,7 +245,7 @@ proptest! {
let block_hash = block::Hash::from(&block);
// Start the runtime
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// All peers will have the current version

View File

@ -27,7 +27,7 @@ fn peer_set_ready_single_connection() {
};
// Start the runtime
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// Get peers and client handles of them
@ -120,7 +120,7 @@ fn peer_set_ready_multiple_connections() {
};
// Start the runtime
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// Pause the runtime's timer so that it advances automatically.
@ -184,7 +184,7 @@ fn peer_set_route_inv_empty_registry() {
};
// Start the runtime
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// Pause the runtime's timer so that it advances automatically.
@ -266,7 +266,7 @@ fn peer_set_route_inv_advertised_registry_order(advertised_first: bool) {
};
// Start the runtime
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// Pause the runtime's timer so that it advances automatically.
@ -375,7 +375,7 @@ fn peer_set_route_inv_missing_registry_order(missing_first: bool) {
};
// Start the runtime
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// Pause the runtime's timer so that it advances automatically.
@ -478,7 +478,7 @@ fn peer_set_route_inv_all_missing_fail() {
};
// Start the runtime
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// Pause the runtime's timer so that it advances automatically.

View File

@ -21,7 +21,7 @@ struct MockKey;
#[tokio::test]
async fn unready_service_result_ok() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (_cancel_sender, cancel) = oneshot::channel();
@ -40,7 +40,7 @@ async fn unready_service_result_ok() {
#[tokio::test]
async fn unready_service_result_canceled() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (cancel_sender, cancel) = oneshot::channel();
@ -63,7 +63,7 @@ async fn unready_service_result_canceled() {
#[tokio::test]
async fn unready_service_result_cancel_handle_dropped() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (cancel_sender, cancel) = oneshot::channel();

View File

@ -761,7 +761,7 @@ mod tests {
/// Check that the version test vector serializes and deserializes correctly
#[test]
fn version_message_round_trip() {
let rt = zebra_test::init_async();
let (rt, _init_guard) = zebra_test::init_async();
let v = &*VERSION_TEST_VECTOR;
@ -814,7 +814,7 @@ mod tests {
/// Deserialize a `Version` message containing `time`, and return the result.
fn deserialize_version_with_time(time: i64) -> Result<Message, Error> {
let rt = zebra_test::init_async();
let (rt, _init_guard) = zebra_test::init_async();
let v = &*VERSION_TEST_VECTOR;
@ -855,7 +855,7 @@ mod tests {
#[test]
fn filterload_message_round_trip() {
let rt = zebra_test::init_async();
let (rt, _init_guard) = zebra_test::init_async();
let v = Message::FilterLoad {
filter: Filter(vec![0; 35999]),
@ -889,7 +889,7 @@ mod tests {
#[test]
fn reject_message_no_extra_data_round_trip() {
let rt = zebra_test::init_async();
let (rt, _init_guard) = zebra_test::init_async();
let v = Message::Reject {
message: "experimental".to_string(),
@ -923,7 +923,7 @@ mod tests {
#[test]
fn reject_message_extra_data_round_trip() {
let rt = zebra_test::init_async();
let (rt, _init_guard) = zebra_test::init_async();
let v = Message::Reject {
message: "block".to_string(),
@ -957,7 +957,7 @@ mod tests {
#[test]
fn filterload_message_too_large_round_trip() {
let rt = zebra_test::init_async();
let (rt, _init_guard) = zebra_test::init_async();
let v = Message::FilterLoad {
filter: Filter(vec![0; 40000]),
@ -991,8 +991,8 @@ mod tests {
fn max_msg_size_round_trip() {
use zebra_chain::serialization::ZcashDeserializeInto;
//let rt = zebra_test::init_async();
zebra_test::init();
//let (rt, _init_guard) = zebra_test::init_async();
let _init_guard = zebra_test::init();
// make tests with a Tx message
let tx: Transaction = zebra_test::vectors::DUMMY_TX1

View File

@ -90,7 +90,7 @@ proptest! {
/// This verifies that our calculated `TrustedPreallocate::max_allocation()` is indeed an upper bound.
#[test]
fn addr_v1_size_is_correct(addr in MetaAddr::arbitrary()) {
zebra_test::init();
let _init_guard = zebra_test::init();
// We require sanitization before serialization
let addr = addr.sanitize(Mainnet);
@ -109,7 +109,7 @@ proptest! {
/// 2. The largest allowed vector is small enough to fit in a legal Zcash message
#[test]
fn addr_v1_max_allocation_is_correct(addr in MetaAddr::arbitrary()) {
zebra_test::init();
let _init_guard = zebra_test::init();
// We require sanitization before serialization
let addr = addr.sanitize(Mainnet);
@ -147,7 +147,7 @@ proptest! {
/// This verifies that our calculated `TrustedPreallocate::max_allocation()` is indeed an upper bound.
#[test]
fn addr_v2_size_is_correct(addr in MetaAddr::arbitrary()) {
zebra_test::init();
let _init_guard = zebra_test::init();
// We require sanitization before serialization
let addr = addr.sanitize(Mainnet);
@ -166,7 +166,7 @@ proptest! {
/// 2. The largest allowed vector is small enough to fit in a legal Zcash message
#[test]
fn addr_v2_max_allocation_is_correct(addr in MetaAddr::arbitrary()) {
zebra_test::init();
let _init_guard = zebra_test::init();
// We require sanitization before serialization
let addr = addr.sanitize(Mainnet);

View File

@ -107,7 +107,7 @@ proptest! {
/// Test round-trip AddrV1 serialization for all MetaAddr variants after sanitization
#[test]
fn addr_v1_sanitized_roundtrip(addr in any::<MetaAddr>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
// We require sanitization before serialization,
// but we also need the original address for this test
@ -180,7 +180,7 @@ proptest! {
/// Test round-trip AddrV2 serialization for all MetaAddr variants after sanitization
#[test]
fn addr_v2_sanitized_roundtrip(addr in any::<MetaAddr>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
// We require sanitization before serialization,
// but we also need the original address for this test

View File

@ -15,7 +15,7 @@ use crate::{
/// Test if deserializing [`InventoryHash::Wtx`] does not produce an error.
#[test]
fn parses_msg_wtx_inventory_type() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut input = Vec::new();
@ -39,7 +39,7 @@ fn parses_msg_wtx_inventory_type() {
/// Also checks some of the deserialized address values.
#[test]
fn parses_msg_addr_v1_ip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let codec = Codec::builder().finish();
@ -104,7 +104,7 @@ fn parses_msg_addr_v1_ip() {
/// and produces no addresses.
#[test]
fn parses_msg_addr_v1_empty() {
zebra_test::init();
let _init_guard = zebra_test::init();
let codec = Codec::builder().finish();
@ -138,7 +138,7 @@ fn parses_msg_addr_v1_empty() {
/// Also checks some of the deserialized address values.
#[test]
fn parses_msg_addr_v2_ip() {
zebra_test::init();
let _init_guard = zebra_test::init();
let codec = Codec::builder().finish();
@ -228,7 +228,7 @@ fn parses_msg_addr_v2_ip() {
/// and produces no addresses.
#[test]
fn parses_msg_addr_v2_empty() {
zebra_test::init();
let _init_guard = zebra_test::init();
let codec = Codec::builder().finish();
@ -259,7 +259,7 @@ fn parses_msg_addr_v2_empty() {
/// Test that deserializing invalid [`AddrV2`] fails.
#[test]
fn parses_msg_addr_v2_invalid() {
zebra_test::init();
let _init_guard = zebra_test::init();
let codec = Codec::builder().finish();

View File

@ -171,7 +171,7 @@ mod proptest {
#[test]
fn magic_debug() {
zebra_test::init();
let _init_guard = zebra_test::init();
assert_eq!(format!("{:?}", magics::MAINNET), "Magic(\"24e92764\")");
assert_eq!(format!("{:?}", magics::TESTNET), "Magic(\"fa1af9bf\")");
@ -181,7 +181,7 @@ mod proptest {
#[test]
fn proptest_magic_from_array(data in any::<[u8; 4]>()) {
zebra_test::init();
let _init_guard = zebra_test::init();
assert_eq!(format!("{:?}", Magic(data)), format!("Magic({:x?})", hex::encode(data)));
}
@ -205,7 +205,7 @@ mod test {
/// Test the min_specified_for_upgrade and min_specified_for_height functions for `network` with
/// extreme values.
fn version_extremes(network: Network) {
zebra_test::init();
let _init_guard = zebra_test::init();
assert_eq!(
Version::min_specified_for_height(network, block::Height(0)),
@ -233,7 +233,7 @@ mod test {
/// Check that the min_specified_for_upgrade and min_specified_for_height functions
/// are consistent for `network`.
fn version_consistent(network: Network) {
zebra_test::init();
let _init_guard = zebra_test::init();
let highest_network_upgrade = NetworkUpgrade::current(network, block::Height::MAX);
assert!(highest_network_upgrade == Nu5 || highest_network_upgrade == Canopy,

View File

@ -43,7 +43,7 @@ proptest = { version = "0.10.1", optional = true }
proptest-derive = { version = "0.3.0", optional = true }
[dev-dependencies]
insta = { version = "1.15.0", features = ["redactions"] }
insta = { version = "1.17.1", features = ["redactions"] }
proptest = "0.10.1"
proptest-derive = "0.3.0"
serde_json = "1.0.83"

View File

@ -34,7 +34,7 @@ proptest! {
/// Test that when sending a raw transaction, it is received by the mempool service.
#[test]
fn mempool_receives_raw_transaction(transaction in any::<Transaction>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
runtime.block_on(async move {
let mut mempool = MockService::build().for_prop_tests();
@ -85,7 +85,7 @@ proptest! {
/// Mempool service errors should become server errors.
#[test]
fn mempool_errors_are_forwarded(transaction in any::<Transaction>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
runtime.block_on(async move {
let mut mempool = MockService::build().for_prop_tests();
@ -142,7 +142,7 @@ proptest! {
/// Test that when the mempool rejects a transaction the caller receives an error.
#[test]
fn rejected_transactions_are_reported(transaction in any::<Transaction>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
runtime.block_on(async move {
let mut mempool = MockService::build().for_prop_tests();
@ -203,7 +203,7 @@ proptest! {
/// non-hexadecimal character, and check that it fails with an expected error.
#[test]
fn non_hexadecimal_string_results_in_an_error(non_hex_string in ".*[^0-9A-Fa-f].*") {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// CORRECTNESS: Nothing in this test depends on real time, so we can speed it up.
@ -255,7 +255,7 @@ proptest! {
/// transaction, and check that it fails with an expected error.
#[test]
fn invalid_transaction_results_in_an_error(random_bytes in any::<Vec<u8>>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// CORRECTNESS: Nothing in this test depends on real time, so we can speed it up.
@ -309,7 +309,7 @@ proptest! {
/// returns those IDs as hexadecimal strings.
#[test]
fn mempool_transactions_are_sent_to_caller(transaction_ids in any::<HashSet<UnminedTxId>>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// CORRECTNESS: Nothing in this test depends on real time, so we can speed it up.
@ -364,7 +364,7 @@ proptest! {
fn get_raw_transaction_non_hexadecimal_string_results_in_an_error(
non_hex_string in ".*[^0-9A-Fa-f].*",
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// CORRECTNESS: Nothing in this test depends on real time, so we can speed it up.
@ -418,7 +418,7 @@ proptest! {
fn get_raw_transaction_invalid_transaction_results_in_an_error(
random_bytes in any::<Vec<u8>>(),
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
// CORRECTNESS: Nothing in this test depends on real time, so we can speed it up.
@ -469,7 +469,7 @@ proptest! {
/// Test the `get_blockchain_info` response when Zebra's state is empty.
#[test]
fn get_blockchain_info_response_without_a_chain_tip(network in any::<Network>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
let mut mempool = MockService::build().for_prop_tests();
let mut state: MockService<_, _, _, BoxError> = MockService::build().for_prop_tests();
@ -506,7 +506,7 @@ proptest! {
network in any::<Network>(),
block in any::<Block>(),
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
let mut mempool = MockService::build().for_prop_tests();
let mut state: MockService<_, _, _, BoxError> = MockService::build().for_prop_tests();
@ -586,7 +586,7 @@ proptest! {
addresses in any::<HashSet<transparent::Address>>(),
balance in any::<Amount<NonNegative>>(),
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
let mut mempool = MockService::build().for_prop_tests();
@ -651,7 +651,7 @@ proptest! {
network in any::<Network>(),
at_least_one_invalid_address in vec(".*", 1..10),
) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
prop_assume!(at_least_one_invalid_address
@ -706,7 +706,7 @@ proptest! {
/// Test the queue functionality using `send_raw_transaction`
#[test]
fn rpc_queue_main_loop(tx in any::<Transaction>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
let transaction_hash = tx.hash();
@ -795,7 +795,7 @@ proptest! {
/// Test we receive all transactions that are sent in a channel
#[test]
fn rpc_queue_receives_all_transactions_from_channel(txs in any::<[Transaction; 2]>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
let _guard = runtime.enter();
runtime.block_on(async move {

View File

@ -18,7 +18,7 @@ use super::super::*;
/// Snapshot test for RPC methods responses.
#[tokio::test(flavor = "multi_thread")]
async fn test_rpc_response_data() {
zebra_test::init();
let _init_guard = zebra_test::init();
test_rpc_response_data_for_network(Mainnet).await;
test_rpc_response_data_for_network(Testnet).await;

View File

@ -22,7 +22,7 @@ use super::super::*;
#[tokio::test(flavor = "multi_thread")]
async fn rpc_getinfo() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
let mut state: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
@ -55,7 +55,7 @@ async fn rpc_getinfo() {
#[tokio::test(flavor = "multi_thread")]
async fn rpc_getblock() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Create a continuous chain of mainnet blocks from genesis
let blocks: Vec<Arc<Block>> = zebra_test::vectors::CONTINUOUS_MAINNET_BLOCKS
@ -115,7 +115,7 @@ async fn rpc_getblock() {
#[tokio::test(flavor = "multi_thread")]
async fn rpc_getblock_parse_error() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
let mut state: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
@ -145,7 +145,7 @@ async fn rpc_getblock_parse_error() {
#[tokio::test(flavor = "multi_thread")]
async fn rpc_getblock_missing_error() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
let mut state: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
@ -197,7 +197,7 @@ async fn rpc_getblock_missing_error() {
#[tokio::test(flavor = "multi_thread")]
async fn rpc_getbestblockhash() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Create a continuous chain of mainnet blocks from genesis
let blocks: Vec<Arc<Block>> = zebra_test::vectors::CONTINUOUS_MAINNET_BLOCKS
@ -243,7 +243,7 @@ async fn rpc_getbestblockhash() {
#[tokio::test(flavor = "multi_thread")]
async fn rpc_getrawtransaction() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Create a continuous chain of mainnet blocks from genesis
let blocks: Vec<Arc<Block>> = zebra_test::vectors::CONTINUOUS_MAINNET_BLOCKS
@ -328,7 +328,7 @@ async fn rpc_getrawtransaction() {
#[tokio::test(flavor = "multi_thread")]
async fn rpc_getaddresstxids_invalid_arguments() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
@ -432,7 +432,7 @@ async fn rpc_getaddresstxids_invalid_arguments() {
#[tokio::test(flavor = "multi_thread")]
async fn rpc_getaddresstxids_response() {
zebra_test::init();
let _init_guard = zebra_test::init();
for network in [Mainnet, Testnet] {
let blocks: Vec<Arc<Block>> = match network {
@ -527,7 +527,7 @@ async fn rpc_getaddresstxids_response_with(
#[tokio::test(flavor = "multi_thread")]
async fn rpc_getaddressutxos_invalid_arguments() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut mempool: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
let mut state: MockService<_, _, _, BoxError> = MockService::build().for_unit_tests();
@ -562,7 +562,7 @@ async fn rpc_getaddressutxos_invalid_arguments() {
#[tokio::test(flavor = "multi_thread")]
async fn rpc_getaddressutxos_response() {
zebra_test::init();
let _init_guard = zebra_test::init();
let blocks: Vec<Arc<Block>> = zebra_test::vectors::CONTINUOUS_MAINNET_BLOCKS
.iter()

View File

@ -101,7 +101,7 @@ proptest! {
/// Test transactions are removed from the queue after time elapses.
#[test]
fn remove_expired_transactions_from_queue(transaction in any::<UnminedTx>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
runtime.block_on(async move {
// pause the clock
@ -159,7 +159,7 @@ proptest! {
/// Test transactions are removed from queue after they get in the mempool
#[test]
fn queue_runner_mempool(transaction in any::<Transaction>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
runtime.block_on(async move {
let mut mempool = MockService::build().for_prop_tests();
@ -239,7 +239,7 @@ proptest! {
/// Test transactions are removed from queue after they get in the state
#[test]
fn queue_runner_state(transaction in any::<Transaction>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
runtime.block_on(async move {
let mut read_state: MockService<_, _, _, BoxError> = MockService::build().for_prop_tests();
@ -314,7 +314,7 @@ proptest! {
// Test any given transaction can be mempool retried.
#[test]
fn queue_mempool_retry(transaction in any::<Transaction>()) {
let runtime = zebra_test::init_async();
let (runtime, _init_guard) = zebra_test::init_async();
runtime.block_on(async move {
let mut mempool = MockService::build().for_prop_tests();

View File

@ -316,7 +316,7 @@ mod tests {
#[test]
fn verify_valid_script_v4() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
verify_valid_script(
Blossom.branch_id().unwrap(),
@ -328,7 +328,7 @@ mod tests {
#[test]
fn count_legacy_sigops() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let transaction =
SCRIPT_TX.zcash_deserialize_into::<Arc<zebra_chain::transaction::Transaction>>()?;
@ -341,7 +341,7 @@ mod tests {
#[test]
fn fail_invalid_script() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let transaction =
SCRIPT_TX.zcash_deserialize_into::<Arc<zebra_chain::transaction::Transaction>>()?;
@ -364,7 +364,7 @@ mod tests {
#[test]
fn reuse_script_verifier_pass_pass() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let coin = u64::pow(10, 8);
let transaction =
@ -391,7 +391,7 @@ mod tests {
#[test]
fn reuse_script_verifier_pass_fail() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let coin = u64::pow(10, 8);
let amount = 212 * coin;
@ -418,7 +418,7 @@ mod tests {
#[test]
fn reuse_script_verifier_fail_pass() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let coin = u64::pow(10, 8);
let amount = 212 * coin;
@ -445,7 +445,7 @@ mod tests {
#[test]
fn reuse_script_verifier_fail_fail() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let coin = u64::pow(10, 8);
let amount = 212 * coin;

View File

@ -47,7 +47,7 @@ once_cell = "1.13.0"
spandoc = "0.2.2"
hex = { version = "0.4.3", features = ["serde"] }
insta = { version = "1.15.0", features = ["ron"] }
insta = { version = "1.17.1", features = ["ron"] }
proptest = "0.10.1"
proptest-derive = "0.3.0"

View File

@ -23,7 +23,7 @@ use crate::{
/// Sprout Spend's referenced anchor is validated.
#[test]
fn check_sprout_anchors() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut state, _genesis) = new_state_with_mainnet_genesis();
@ -133,7 +133,7 @@ fn prepare_sprout_block(mut block_to_prepare: Block, reference_block: Block) ->
/// validated.
#[test]
fn check_sapling_anchors() {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut state, _genesis) = new_state_with_mainnet_genesis();

View File

@ -56,7 +56,7 @@ proptest! {
joinsplit_data in TypeNameToDebug::<JoinSplitData<Groth16Proof>>::arbitrary(),
use_finalized_state in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -127,7 +127,7 @@ proptest! {
mut joinsplit in TypeNameToDebug::<JoinSplit<Groth16Proof>>::arbitrary(),
joinsplit_data in TypeNameToDebug::<JoinSplitData<Groth16Proof>>::arbitrary(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -177,7 +177,7 @@ proptest! {
mut joinsplit2 in TypeNameToDebug::<JoinSplit<Groth16Proof>>::arbitrary(),
joinsplit_data in TypeNameToDebug::<JoinSplitData<Groth16Proof>>::arbitrary(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -232,7 +232,7 @@ proptest! {
joinsplit_data1 in TypeNameToDebug::<JoinSplitData<Groth16Proof>>::arbitrary(),
joinsplit_data2 in TypeNameToDebug::<JoinSplitData<Groth16Proof>>::arbitrary(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -290,7 +290,7 @@ proptest! {
joinsplit_data2 in TypeNameToDebug::<JoinSplitData<Groth16Proof>>::arbitrary(),
duplicate_in_finalized_state in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -390,7 +390,7 @@ proptest! {
sapling_shielded_data in TypeNameToDebug::<sapling::ShieldedData<PerSpendAnchor>>::arbitrary(),
use_finalized_state in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -443,7 +443,7 @@ proptest! {
mut spend2 in TypeNameToDebug::<sapling::Spend<PerSpendAnchor>>::arbitrary(),
sapling_shielded_data in TypeNameToDebug::<sapling::ShieldedData<PerSpendAnchor>>::arbitrary(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -493,7 +493,7 @@ proptest! {
sapling_shielded_data1 in TypeNameToDebug::<sapling::ShieldedData<PerSpendAnchor>>::arbitrary(),
sapling_shielded_data2 in TypeNameToDebug::<sapling::ShieldedData<PerSpendAnchor>>::arbitrary(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -546,7 +546,7 @@ proptest! {
sapling_shielded_data2 in TypeNameToDebug::<sapling::ShieldedData<PerSpendAnchor>>::arbitrary(),
duplicate_in_finalized_state in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -632,7 +632,7 @@ proptest! {
orchard_shielded_data in TypeNameToDebug::<orchard::ShieldedData>::arbitrary(),
use_finalized_state in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -687,7 +687,7 @@ proptest! {
mut authorized_action2 in TypeNameToDebug::<orchard::AuthorizedAction>::arbitrary(),
orchard_shielded_data in TypeNameToDebug::<orchard::ShieldedData>::arbitrary(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -737,7 +737,7 @@ proptest! {
orchard_shielded_data1 in TypeNameToDebug::<orchard::ShieldedData>::arbitrary(),
orchard_shielded_data2 in TypeNameToDebug::<orchard::ShieldedData>::arbitrary(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -794,7 +794,7 @@ proptest! {
orchard_shielded_data2 in TypeNameToDebug::<orchard::ShieldedData>::arbitrary(),
duplicate_in_finalized_state in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()

View File

@ -32,7 +32,7 @@ use crate::{
/// (And that the test infrastructure generally works.)
#[test]
fn accept_shielded_mature_coinbase_utxo_spend() {
zebra_test::init();
let _init_guard = zebra_test::init();
let created_height = Height(1);
let outpoint = transparent::OutPoint {
@ -58,7 +58,7 @@ fn accept_shielded_mature_coinbase_utxo_spend() {
/// Check that non-shielded spends of coinbase transparent outputs fail.
#[test]
fn reject_unshielded_coinbase_utxo_spend() {
zebra_test::init();
let _init_guard = zebra_test::init();
let created_height = Height(1);
let outpoint = transparent::OutPoint {
@ -80,7 +80,7 @@ fn reject_unshielded_coinbase_utxo_spend() {
/// Check that early spends of coinbase transparent outputs fail.
#[test]
fn reject_immature_coinbase_utxo_spend() {
zebra_test::init();
let _init_guard = zebra_test::init();
let created_height = Height(1);
let outpoint = transparent::OutPoint {
@ -142,7 +142,7 @@ proptest! {
mut prevout_input in TypeNameToDebug::<transparent::Input>::arbitrary_with(None),
use_finalized_state in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -226,7 +226,7 @@ proptest! {
use_finalized_state_output in any::<bool>(),
mut use_finalized_state_spend in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
// if we use the non-finalized state for the first block,
// we have to use it for the second as well
@ -320,7 +320,7 @@ proptest! {
mut prevout_input1 in TypeNameToDebug::<transparent::Input>::arbitrary_with(None),
mut prevout_input2 in TypeNameToDebug::<transparent::Input>::arbitrary_with(None),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -382,7 +382,7 @@ proptest! {
mut prevout_input2 in TypeNameToDebug::<transparent::Input>::arbitrary_with(None),
use_finalized_state_output in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block2 = zebra_test::vectors::BLOCK_MAINNET_2_BYTES
.zcash_deserialize_into::<Block>()
@ -458,7 +458,7 @@ proptest! {
mut prevout_input2 in TypeNameToDebug::<transparent::Input>::arbitrary_with(None),
use_finalized_state_output in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block2 = zebra_test::vectors::BLOCK_MAINNET_2_BYTES
.zcash_deserialize_into::<Block>()
@ -542,7 +542,7 @@ proptest! {
use_finalized_state_output in any::<bool>(),
mut use_finalized_state_spend in any::<bool>(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
// if we use the non-finalized state for the first block,
// we have to use it for the second as well
@ -690,7 +690,7 @@ proptest! {
unused_output in TypeNameToDebug::<transparent::Output>::arbitrary(),
prevout_input in TypeNameToDebug::<transparent::Input>::arbitrary_with(None),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()
@ -743,7 +743,7 @@ proptest! {
output in TypeNameToDebug::<transparent::Output>::arbitrary(),
mut prevout_input in TypeNameToDebug::<transparent::Input>::arbitrary_with(None),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block1 = zebra_test::vectors::BLOCK_MAINNET_1_BYTES
.zcash_deserialize_into::<Block>()

View File

@ -8,7 +8,7 @@ use super::super::*;
#[test]
fn test_orphan_consensus_check() {
zebra_test::init();
let _init_guard = zebra_test::init();
let height = zebra_test::vectors::BLOCK_MAINNET_347499_BYTES
.zcash_deserialize_into::<Arc<Block>>()
@ -27,7 +27,7 @@ fn test_orphan_consensus_check() {
#[test]
fn test_sequential_height_check() {
zebra_test::init();
let _init_guard = zebra_test::init();
let height = zebra_test::vectors::BLOCK_MAINNET_347499_BYTES
.zcash_deserialize_into::<Arc<Block>>()

View File

@ -28,7 +28,7 @@ use crate::service::finalized_state::{
// TODO: turn this into a unit test, it has a fixed value
#[test]
fn roundtrip_unit_type() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val in any::<()>())| assert_value_properties(val));
}
@ -38,7 +38,7 @@ fn roundtrip_unit_type() {
#[test]
fn roundtrip_block_height() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
|(mut val in any::<Height>())| {
@ -53,14 +53,14 @@ fn roundtrip_block_height() {
#[test]
fn roundtrip_block_hash() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val in any::<block::Hash>())| assert_value_properties(val));
}
#[test]
fn roundtrip_block_header() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val in any::<block::Header>())| assert_value_properties(val));
}
@ -69,7 +69,7 @@ fn roundtrip_block_header() {
#[test]
fn roundtrip_transaction_location() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
|(mut val in any::<TransactionLocation>())| {
@ -81,14 +81,14 @@ fn roundtrip_transaction_location() {
#[test]
fn roundtrip_transaction_hash() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val in any::<transaction::Hash>())| assert_value_properties(val));
}
#[test]
fn roundtrip_transaction() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val in any::<Transaction>())| assert_value_properties(val));
}
@ -98,7 +98,7 @@ fn roundtrip_transaction() {
// TODO: turn this into a generic function like assert_value_properties()
#[test]
fn serialized_transparent_address_equal() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val1 in any::<transparent::Address>(), val2 in any::<transparent::Address>())| {
if val1 == val2 {
@ -130,14 +130,14 @@ fn serialized_transparent_address_equal() {
#[test]
fn roundtrip_transparent_address() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val in any::<transparent::Address>())| assert_value_properties(val));
}
#[test]
fn roundtrip_output_location() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
|(mut val in any::<OutputLocation>())| {
@ -149,7 +149,7 @@ fn roundtrip_output_location() {
#[test]
fn roundtrip_address_location() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
|(mut val in any::<AddressLocation>())| {
@ -161,7 +161,7 @@ fn roundtrip_address_location() {
#[test]
fn roundtrip_address_balance_location() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
|(mut val in any::<AddressBalanceLocation>())| {
@ -173,14 +173,14 @@ fn roundtrip_address_balance_location() {
#[test]
fn roundtrip_transparent_output() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val in any::<transparent::Output>())| assert_value_properties(val));
}
#[test]
fn roundtrip_address_unspent_output() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
|(mut val in any::<AddressUnspentOutput>())| {
@ -194,7 +194,7 @@ fn roundtrip_address_unspent_output() {
#[test]
fn roundtrip_address_transaction() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
|(mut val in any::<AddressTransaction>())| {
@ -208,7 +208,7 @@ fn roundtrip_address_transaction() {
#[test]
fn roundtrip_amount() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val in any::<Amount::<NonNegative>>())| assert_value_properties(val));
}
@ -217,7 +217,7 @@ fn roundtrip_amount() {
#[test]
fn serialized_sprout_nullifier_equal() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val1 in any::<sprout::Nullifier>(), val2 in any::<sprout::Nullifier>())| {
if val1 == val2 {
@ -249,7 +249,7 @@ fn serialized_sprout_nullifier_equal() {
#[test]
fn serialized_sprout_tree_root_equal() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val1 in any::<sprout::tree::Root>(), val2 in any::<sprout::tree::Root>())| {
if val1 == val2 {
@ -285,7 +285,7 @@ fn serialized_sprout_tree_root_equal() {
#[test]
fn serialized_sapling_nullifier_equal() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val1 in any::<sapling::Nullifier>(), val2 in any::<sapling::Nullifier>())| {
if val1 == val2 {
@ -317,7 +317,7 @@ fn serialized_sapling_nullifier_equal() {
#[test]
fn serialized_sapling_tree_root_equal() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val1 in any::<sapling::tree::Root>(), val2 in any::<sapling::tree::Root>())| {
if val1 == val2 {
@ -353,7 +353,7 @@ fn serialized_sapling_tree_root_equal() {
#[test]
fn serialized_orchard_nullifier_equal() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val1 in any::<orchard::Nullifier>(), val2 in any::<orchard::Nullifier>())| {
if val1 == val2 {
@ -385,7 +385,7 @@ fn serialized_orchard_nullifier_equal() {
#[test]
fn serialized_orchard_tree_root_equal() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val1 in any::<orchard::tree::Root>(), val2 in any::<orchard::tree::Root>())| {
if val1 == val2 {
@ -423,7 +423,7 @@ fn serialized_orchard_tree_root_equal() {
#[test]
fn roundtrip_value_balance() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(val in any::<ValueBalance::<NonNegative>>())| assert_value_properties(val));
}

View File

@ -45,7 +45,7 @@ use crate::{
/// These snapshots contain the `default` column family, but it is not used by Zebra.
#[test]
fn test_raw_rocksdb_column_families() {
zebra_test::init();
let _init_guard = zebra_test::init();
test_raw_rocksdb_column_families_with_network(Mainnet);
test_raw_rocksdb_column_families_with_network(Testnet);

View File

@ -18,7 +18,7 @@ const DEFAULT_PARTIAL_CHAIN_PROPTEST_CASES: u32 = 1;
#[test]
fn blocks_with_v5_transactions() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(ProptestConfig::with_cases(env::var("PROPTEST_CASES")
.ok()
.and_then(|v| v.parse().ok())
@ -50,7 +50,7 @@ fn blocks_with_v5_transactions() -> Result<()> {
#[test]
#[allow(clippy::print_stderr)]
fn all_upgrades_and_wrong_commitments_with_fake_activation_heights() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
if std::env::var_os("TEST_FAKE_ACTIVATION_HEIGHTS").is_none() {
eprintln!("Skipping all_upgrades_and_wrong_commitments_with_fake_activation_heights() since $TEST_FAKE_ACTIVATION_HEIGHTS is NOT set");

View File

@ -8,7 +8,7 @@ use zebra_chain::{orchard, sapling};
#[test]
fn sapling_note_commitment_tree_serialization() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut incremental_tree = sapling::tree::NoteCommitmentTree::default();
@ -47,7 +47,7 @@ fn sapling_note_commitment_tree_serialization() {
#[test]
fn orchard_note_commitment_tree_serialization() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut incremental_tree = orchard::tree::NoteCommitmentTree::default();

View File

@ -152,7 +152,7 @@ impl TransactionData {
/// Snapshot test for finalized block and transaction data.
#[test]
fn test_block_and_transaction_data() {
zebra_test::init();
let _init_guard = zebra_test::init();
test_block_and_transaction_data_with_network(Mainnet);
test_block_and_transaction_data_with_network(Testnet);

View File

@ -75,7 +75,7 @@ fn test_block_db_round_trip_with(
network: Network,
block_test_cases: impl IntoIterator<Item = Block>,
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let state = FinalizedState::new(&Config::ephemeral(), network);

View File

@ -196,7 +196,7 @@ mod tests {
#[test]
fn dequeue_gives_right_children() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block1: Arc<Block> =
zebra_test::vectors::BLOCK_MAINNET_419200_BYTES.zcash_deserialize_into()?;
@ -267,7 +267,7 @@ mod tests {
#[test]
fn prune_removes_right_children() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block1: Arc<Block> =
zebra_test::vectors::BLOCK_MAINNET_419200_BYTES.zcash_deserialize_into()?;

View File

@ -37,7 +37,7 @@ const DEFAULT_SHORT_CHAIN_PROPTEST_CASES: u32 = 16;
/// Logs extra debugging information when the chain value balances fail.
#[test]
fn push_genesis_chain() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
ProptestConfig::with_cases(env::var("PROPTEST_CASES")
@ -81,7 +81,7 @@ fn push_genesis_chain() -> Result<()> {
/// Check that chain block pushes work with history tree blocks
#[test]
fn push_history_tree_chain() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
ProptestConfig::with_cases(env::var("PROPTEST_CASES")
@ -129,7 +129,7 @@ fn push_history_tree_chain() -> Result<()> {
/// - Chain value balances are non-negative.
#[test]
fn forked_equals_pushed_genesis() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
ProptestConfig::with_cases(env::var("PROPTEST_CASES")
@ -234,7 +234,7 @@ fn forked_equals_pushed_genesis() -> Result<()> {
/// Check that a forked history tree chain is the same as a chain that had the same blocks appended.
#[test]
fn forked_equals_pushed_history_tree() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(
ProptestConfig::with_cases(env::var("PROPTEST_CASES")
@ -305,7 +305,7 @@ fn forked_equals_pushed_history_tree() -> Result<()> {
/// a chain that never had those blocks added.
#[test]
fn finalized_equals_pushed_genesis() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(ProptestConfig::with_cases(env::var("PROPTEST_CASES")
.ok()
@ -368,7 +368,7 @@ fn finalized_equals_pushed_genesis() -> Result<()> {
/// a chain that never had those blocks added.
#[test]
fn finalized_equals_pushed_history_tree() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(ProptestConfig::with_cases(env::var("PROPTEST_CASES")
.ok()
@ -439,7 +439,7 @@ fn finalized_equals_pushed_history_tree() -> Result<()> {
/// in a non-finalized state.
#[test]
fn rejection_restores_internal_state_genesis() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(ProptestConfig::with_cases(env::var("PROPTEST_CASES")
.ok()
@ -532,7 +532,7 @@ fn rejection_restores_internal_state_genesis() -> Result<()> {
/// and that all the state fields are covered by `eq_internal_state`.
#[test]
fn different_blocks_different_chains() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(ProptestConfig::with_cases(env::var("PROPTEST_CASES")
.ok()

View File

@ -24,7 +24,7 @@ use crate::{
#[test]
fn construct_empty() {
zebra_test::init();
let _init_guard = zebra_test::init();
let _chain = Chain::new(
Network::Mainnet,
Default::default(),
@ -37,7 +37,7 @@ fn construct_empty() {
#[test]
fn construct_single() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block: Arc<Block> =
zebra_test::vectors::BLOCK_MAINNET_434873_BYTES.zcash_deserialize_into()?;
@ -59,7 +59,7 @@ fn construct_single() -> Result<()> {
#[test]
fn construct_many() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut block: Arc<Block> =
zebra_test::vectors::BLOCK_MAINNET_434873_BYTES.zcash_deserialize_into()?;
@ -91,7 +91,7 @@ fn construct_many() -> Result<()> {
#[test]
fn ord_matches_work() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let less_block = zebra_test::vectors::BLOCK_MAINNET_434873_BYTES
.zcash_deserialize_into::<Arc<Block>>()?
.set_work(1);
@ -124,7 +124,7 @@ fn ord_matches_work() -> Result<()> {
#[test]
fn best_chain_wins() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
best_chain_wins_for_network(Network::Mainnet)?;
best_chain_wins_for_network(Network::Testnet)?;
@ -164,7 +164,7 @@ fn best_chain_wins_for_network(network: Network) -> Result<()> {
#[test]
fn finalize_pops_from_best_chain() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
finalize_pops_from_best_chain_for_network(Network::Mainnet)?;
finalize_pops_from_best_chain_for_network(Network::Testnet)?;
@ -212,7 +212,7 @@ fn finalize_pops_from_best_chain_for_network(network: Network) -> Result<()> {
#[test]
// This test gives full coverage for `take_chain_if`
fn commit_block_extending_best_chain_doesnt_drop_worst_chains() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
commit_block_extending_best_chain_doesnt_drop_worst_chains_for_network(Network::Mainnet)?;
commit_block_extending_best_chain_doesnt_drop_worst_chains_for_network(Network::Testnet)?;
@ -260,7 +260,7 @@ fn commit_block_extending_best_chain_doesnt_drop_worst_chains_for_network(
#[test]
fn shorter_chain_can_be_best_chain() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
shorter_chain_can_be_best_chain_for_network(Network::Mainnet)?;
shorter_chain_can_be_best_chain_for_network(Network::Testnet)?;
@ -305,7 +305,7 @@ fn shorter_chain_can_be_best_chain_for_network(network: Network) -> Result<()> {
#[test]
fn longer_chain_with_more_work_wins() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
longer_chain_with_more_work_wins_for_network(Network::Mainnet)?;
longer_chain_with_more_work_wins_for_network(Network::Testnet)?;
@ -354,7 +354,7 @@ fn longer_chain_with_more_work_wins_for_network(network: Network) -> Result<()>
#[test]
fn equal_length_goes_to_more_work() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
equal_length_goes_to_more_work_for_network(Network::Mainnet)?;
equal_length_goes_to_more_work_for_network(Network::Testnet)?;

View File

@ -16,7 +16,7 @@ use crate::{init_test_services, populated_state, ReadRequest, ReadResponse};
/// Test that ReadStateService responds correctly when empty.
#[tokio::test]
async fn empty_read_state_still_responds_to_requests() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let transcript = Transcript::from(empty_state_test_cases());
@ -31,7 +31,7 @@ async fn empty_read_state_still_responds_to_requests() -> Result<()> {
/// Test that ReadStateService responds correctly when the state contains blocks.
#[tokio::test(flavor = "multi_thread")]
async fn populated_read_state_responds_correctly() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Create a continuous chain of mainnet blocks from genesis
let blocks: Vec<Arc<Block>> = zebra_test::vectors::CONTINUOUS_MAINNET_BLOCKS

View File

@ -210,7 +210,7 @@ fn out_of_order_committing_strategy() -> BoxedStrategy<Vec<Arc<Block>>> {
#[tokio::test(flavor = "multi_thread")]
async fn empty_state_still_responds_to_requests() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let block =
zebra_test::vectors::BLOCK_MAINNET_419200_BYTES.zcash_deserialize_into::<Arc<Block>>()?;
@ -262,7 +262,7 @@ async fn empty_state_still_responds_to_requests() -> Result<()> {
#[test]
fn state_behaves_when_blocks_are_committed_in_order() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
let blocks = zebra_test::vectors::MAINNET_BLOCKS
.range(0..=LAST_BLOCK_HEIGHT)
@ -293,7 +293,7 @@ proptest! {
/// Test out of order commits of continuous block test vectors from genesis onward.
#[test]
fn state_behaves_when_blocks_are_committed_out_of_order(blocks in out_of_order_committing_strategy()) {
zebra_test::init();
let _init_guard = zebra_test::init();
populate_and_check(blocks).unwrap();
}
@ -386,7 +386,7 @@ proptest! {
(network, finalized_blocks, non_finalized_blocks)
in continuous_empty_blocks_from_test_vectors(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut state_service, _read_only_state_service, latest_chain_tip, mut chain_tip_change) = StateService::new(Config::ephemeral(), network);
@ -439,7 +439,7 @@ proptest! {
(network, finalized_blocks, non_finalized_blocks)
in continuous_empty_blocks_from_test_vectors(),
) {
zebra_test::init();
let _init_guard = zebra_test::init();
let (mut state_service, _, _, _) = StateService::new(Config::ephemeral(), network);

View File

@ -94,7 +94,7 @@ use proptest::prelude::*;
#[test]
fn round_trip_work_expanded() {
zebra_test::init();
let _init_guard = zebra_test::init();
proptest!(|(work_before in any::<Work>())| {
let work: U256 = work_before.as_u128().into();
@ -107,7 +107,7 @@ fn round_trip_work_expanded() {
/// Check that the block locator heights are sensible.
#[test]
fn test_block_locator_heights() {
zebra_test::init();
let _init_guard = zebra_test::init();
for (height, min_height) in BLOCK_LOCATOR_CASES.iter().cloned() {
let locator = util::block_locator_heights(block::Height(height));

View File

@ -64,7 +64,7 @@ async fn check_transcripts_testnet() -> Result<(), Report> {
#[spandoc::spandoc]
async fn check_transcripts(network: Network) -> Result<(), Report> {
zebra_test::init();
let _init_guard = zebra_test::init();
let mainnet_transcript = &[&COMMIT_FINALIZED_BLOCK_MAINNET];
let testnet_transcript = &[&COMMIT_FINALIZED_BLOCK_TESTNET];

View File

@ -11,7 +11,7 @@ edition = "2021"
hex = "0.4.3"
indexmap = "1.9.1"
lazy_static = "1.4.0"
insta = "1.15.0"
insta = "1.17.1"
proptest = "0.10.1"
once_cell = "1.13.0"
rand = { version = "0.8.5", package = "rand" }

View File

@ -65,14 +65,18 @@ static INIT: Once = Once::new();
/// such as tracing configs, panic hooks, and `cargo insta` settings.
///
/// This function should be called at the start of every test.
pub fn init() {
///
/// It returns a drop guard that must be stored in a variable, so that it
/// gets dropped when the test finishes.
#[must_use]
pub fn init() -> impl Drop {
// Per-test
// Settings for threads that snapshots data using `insta`
let mut settings = insta::Settings::clone_current();
settings.set_prepend_module_to_snapshot(false);
settings.bind_to_thread();
let drop_guard = settings.bind_to_scope();
// Globals
@ -139,7 +143,9 @@ pub fn init() {
.panic_message(SkipTestReturnedErrPanicMessages)
.install()
.unwrap();
})
});
drop_guard
}
/// Initialize globals for tests that need a separate Tokio runtime instance.
@ -150,13 +156,16 @@ pub fn init() {
/// [`MULTI_THREADED_RUNTIME`] instances instead.
///
/// See also the [`init`] function, which is called by this function.
pub fn init_async() -> tokio::runtime::Runtime {
init();
pub fn init_async() -> (tokio::runtime::Runtime, impl Drop) {
let drop_guard = init();
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("Failed to create Tokio runtime")
(
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("Failed to create Tokio runtime"),
drop_guard,
)
}
struct SkipTestReturnedErrPanicMessages;

View File

@ -878,7 +878,7 @@ mod test {
#[test]
fn block_test_vectors_unique() {
init();
let _init_guard = init();
let block_count = BLOCKS.len();
let block_set: HashSet<_> = BLOCKS.iter().collect();
@ -898,7 +898,7 @@ mod test {
/// We're using lazy_static! and combinators, so it would be easy to make this mistake.
#[test]
fn block_test_vectors_count() {
init();
let _init_guard = init();
assert!(
MAINNET_BLOCKS.len() > 30,

View File

@ -46,7 +46,7 @@ fn is_command_available(cmd: &str, args: &[&str]) -> bool {
/// Test if a process that keeps on producing lines of output is killed after the timeout.
#[test]
fn kill_on_timeout_output_continuous_lines() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
// Ideally, we'd want to use the 'yes' command here, but BSD yes treats
// every string as an argument to repeat - so we can't test if it is
@ -78,7 +78,7 @@ fn kill_on_timeout_output_continuous_lines() -> Result<()> {
// TODO: create a similar test that pauses after output (#1140)
#[test]
fn finish_before_timeout_output_single_line() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "echo";
// Skip the test if the test system does not have the command
@ -107,7 +107,7 @@ fn finish_before_timeout_output_single_line() -> Result<()> {
//#[ignore]
#[allow(dead_code)]
fn kill_on_timeout_continuous_output_no_newlines() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "head";
// Skip the test if the test system does not have the command
@ -134,7 +134,7 @@ fn kill_on_timeout_continuous_output_no_newlines() -> Result<()> {
// TODO: create a similar test that pauses after output (#1140)
#[test]
fn finish_before_timeout_short_output_no_newlines() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "printf";
// Skip the test if the test system does not have the command
@ -163,7 +163,7 @@ fn finish_before_timeout_short_output_no_newlines() -> Result<()> {
// #[ignore]
#[allow(dead_code)]
fn kill_on_timeout_no_output() -> Result<()> {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "sleep";
// Skip the test if the test system does not have the command
@ -189,7 +189,7 @@ fn kill_on_timeout_no_output() -> Result<()> {
#[test]
#[should_panic(expected = "Logged a failure message")]
fn failure_regex_matches_stdout_failure_message() {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "echo";
// Skip the test if the test system does not have the command
@ -219,7 +219,7 @@ fn failure_regex_matches_stdout_failure_message() {
#[test]
#[should_panic(expected = "Logged a failure message")]
fn failure_regex_matches_stderr_failure_message() {
zebra_test::init();
let _init_guard = zebra_test::init();
// The read command prints its prompt to stderr.
//
@ -255,7 +255,7 @@ fn failure_regex_matches_stderr_failure_message() {
#[test]
#[should_panic(expected = "Logged a failure message")]
fn failure_regex_matches_stdout_failure_message_drop() {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "echo";
// Skip the test if the test system does not have the command
@ -284,7 +284,7 @@ fn failure_regex_matches_stdout_failure_message_drop() {
#[test]
#[should_panic(expected = "Logged a failure message")]
fn failure_regex_matches_stdout_failure_message_kill() {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "echo";
// Skip the test if the test system does not have the command
@ -315,7 +315,7 @@ fn failure_regex_matches_stdout_failure_message_kill() {
#[test]
#[should_panic(expected = "Logged a failure message")]
fn failure_regex_matches_stdout_failure_message_kill_on_error() {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "echo";
// Skip the test if the test system does not have the command
@ -347,7 +347,7 @@ fn failure_regex_matches_stdout_failure_message_kill_on_error() {
#[test]
#[should_panic(expected = "Logged a failure message")]
fn failure_regex_matches_stdout_failure_message_no_kill_on_error() {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "echo";
// Skip the test if the test system does not have the command
@ -381,7 +381,7 @@ fn failure_regex_matches_stdout_failure_message_no_kill_on_error() {
#[test]
#[should_panic(expected = "Logged a failure message")]
fn failure_regex_timeout_continuous_output() {
zebra_test::init();
let _init_guard = zebra_test::init();
// Ideally, we'd want to use the 'yes' command here, but BSD yes treats
// every string as an argument to repeat - so we can't test if it is
@ -418,7 +418,7 @@ fn failure_regex_timeout_continuous_output() {
#[test]
#[should_panic(expected = "Logged a failure message")]
fn failure_regex_matches_stdout_failure_message_wait_for_output() {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "echo";
// Skip the test if the test system does not have the command
@ -449,7 +449,7 @@ fn failure_regex_matches_stdout_failure_message_wait_for_output() {
#[test]
#[should_panic(expected = "Logged a failure message")]
fn failure_regex_iter_matches_stdout_failure_message() {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "echo";
// Skip the test if the test system does not have the command
@ -480,7 +480,7 @@ fn failure_regex_iter_matches_stdout_failure_message() {
/// Make sure ignore regexes override failure regexes.
#[test]
fn ignore_regex_ignores_stdout_failure_message() {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "echo";
// Skip the test if the test system does not have the command
@ -502,7 +502,7 @@ fn ignore_regex_ignores_stdout_failure_message() {
/// Make sure ignore regex iters override failure regex iters.
#[test]
fn ignore_regex_iter_ignores_stdout_failure_message() {
zebra_test::init();
let _init_guard = zebra_test::init();
const TEST_CMD: &str = "echo";
// Skip the test if the test system does not have the command

View File

@ -11,7 +11,7 @@ const TRANSCRIPT_DATA: [(&str, Result<&str, ExpectedTranscriptError>); 4] = [
#[tokio::test]
async fn transcript_returns_responses_and_ends() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut svc = Transcript::from(TRANSCRIPT_DATA.iter().cloned());
@ -26,7 +26,7 @@ async fn transcript_returns_responses_and_ends() {
#[tokio::test]
async fn transcript_errors_wrong_request() {
zebra_test::init();
let _init_guard = zebra_test::init();
let mut svc = Transcript::from(TRANSCRIPT_DATA.iter().cloned());
@ -39,7 +39,7 @@ async fn transcript_errors_wrong_request() {
#[tokio::test]
async fn self_check() {
zebra_test::init();
let _init_guard = zebra_test::init();
let t1 = Transcript::from(TRANSCRIPT_DATA.iter().cloned());
let t2 = Transcript::from(TRANSCRIPT_DATA.iter().cloned());
@ -59,7 +59,7 @@ const TRANSCRIPT_DATA2: [(&str, Result<&str, ExpectedTranscriptError>); 4] = [
#[tokio::test]
async fn self_check_err() {
zebra_test::init();
let _init_guard = zebra_test::init();
let t1 = Transcript::from(TRANSCRIPT_DATA2.iter().cloned());
let t2 = Transcript::from(TRANSCRIPT_DATA2.iter().cloned());

Some files were not shown because too many files have changed in this diff Show More