From fc2876ba10f4a22baeecc337255c6661318b5c85 Mon Sep 17 00:00:00 2001 From: "Jamil Lambert, PhD" Date: Thu, 13 Jun 2024 17:07:06 +0100 Subject: [PATCH] Move use statements to top of module Moved all of the use statements to the top of the tests module. Change to have one level of path instead of importing the function name. --- bitcoin/src/merkle_tree/block.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/bitcoin/src/merkle_tree/block.rs b/bitcoin/src/merkle_tree/block.rs index 7f93a6914..fd851a79a 100644 --- a/bitcoin/src/merkle_tree/block.rs +++ b/bitcoin/src/merkle_tree/block.rs @@ -514,14 +514,18 @@ impl std::error::Error for MerkleBlockError { #[cfg(test)] mod tests { - use hex::test_hex_unwrap as hex; - #[cfg(feature = "rand-std")] - use secp256k1::rand::prelude::*; - use super::*; + use crate::consensus::encode; use crate::hash_types::Txid; - use crate::hex::FromHex; + use crate::hex::{FromHex, test_hex_unwrap as hex}; + + #[cfg(feature = "rand-std")] + use { + core::cmp, + secp256k1::rand::prelude::*, + crate::merkle_tree, + }; #[cfg(feature = "rand-std")] macro_rules! pmt_tests { @@ -557,10 +561,6 @@ mod tests { #[cfg(feature = "rand-std")] fn pmt_test(tx_count: usize) { - use core::cmp::min; - - use crate::merkle_tree; - let mut rng = thread_rng(); // Create some fake tx ids let tx_ids = (1..=tx_count) @@ -601,7 +601,7 @@ mod tests { let serialized = encode::serialize(&pmt1); // Verify PartialMerkleTree's size guarantees - let n = min(tx_count, 1 + match_txid1.len() * height); + let n = cmp::min(tx_count, 1 + match_txid1.len() * height); assert!(serialized.len() <= 10 + (258 * n + 7) / 8); // Deserialize into a tester copy @@ -745,7 +745,6 @@ mod tests { /// Returns a real block (0000000000013b8ab2cd513b0261a14096412195a72a0c4827d229dcc7e0f7af) /// with 9 txs. fn get_block_13b8a() -> Block { - use hex::FromHex; let block_hex = include_str!("../../tests/data/block_13b8a.hex"); encode::deserialize(&Vec::from_hex(block_hex).unwrap()).unwrap() } @@ -811,7 +810,7 @@ mod tests { 00000004bfaac251681b1b25\ " ); - let deser = crate::consensus::deserialize::(&bytes); + let deser = encode::deserialize::(&bytes); assert!(deser.is_err()); }