diff --git a/src/util/address.rs b/src/util/address.rs index 0d9b4f1e..2c4f9782 100644 --- a/src/util/address.rs +++ b/src/util/address.rs @@ -988,7 +988,7 @@ mod tests { let addr = Address::p2pkh(&key, Bitcoin); assert_eq!(&addr.to_string(), "1QJVDzdqb1VpbDK7uDeyVXy9mR27CJiyhY"); - let key = hex_key!(&"03df154ebfcf29d29cc10d5c2565018bce2d9edbab267c31d2caf44a63056cf99f"); + let key = hex_key!("03df154ebfcf29d29cc10d5c2565018bce2d9edbab267c31d2caf44a63056cf99f"); let addr = Address::p2pkh(&key, Testnet); assert_eq!(&addr.to_string(), "mqkhEMH6NCeYjFybv7pvFC22MFeaNT9AQC"); assert_eq!(addr.address_type(), Some(AddressType::P2pkh)); @@ -1108,7 +1108,7 @@ mod tests { ("bc1zw508d6qejxtdg4y5r3zarvaryvaxxpcs", None), ]; for (address, expected_type) in &addresses { - let addr = Address::from_str(&address).unwrap(); + let addr = Address::from_str(address).unwrap(); assert_eq!(&addr.address_type(), expected_type); } } diff --git a/src/util/base58.rs b/src/util/base58.rs index c4bf0326..7aa69d69 100644 --- a/src/util/base58.rs +++ b/src/util/base58.rs @@ -299,7 +299,7 @@ mod tests { assert_eq!(&encode_slice(&[0, 0, 0, 0, 13, 36][..]), "1111211"); // Long input (>100 bytes => has to use heap) - let res = encode_slice(&"BitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBit\ + let res = encode_slice("BitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBit\ coinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoinBitcoin".as_bytes()); let exp = "ZqC5ZdfpZRi7fjA8hbhX5pEE96MdH9hEaC1YouxscPtbJF16qVWksHWR4wwvx7MotFcs2ChbJqK8KJ9X\ wZznwWn1JFDhhTmGo9v6GjAVikzCsBWZehu7bm22xL8b5zBR5AsBygYRwbFJsNwNkjpyFuDKwmsUTKvkULCvucPJrN5\ diff --git a/src/util/bip158.rs b/src/util/bip158.rs index a9fe4819..3b823f00 100644 --- a/src/util/bip158.rs +++ b/src/util/bip158.rs @@ -542,13 +542,13 @@ mod test { let testdata = serde_json::from_str::(data).unwrap().as_array().unwrap().clone(); for t in testdata.iter().skip(1) { - let block_hash = BlockHash::from_hex(&t.get(1).unwrap().as_str().unwrap()).unwrap(); - let block: Block = deserialize(&Vec::from_hex(&t.get(2).unwrap().as_str().unwrap()).unwrap()).unwrap(); + let block_hash = BlockHash::from_hex(t.get(1).unwrap().as_str().unwrap()).unwrap(); + let block: Block = deserialize(&Vec::from_hex(t.get(2).unwrap().as_str().unwrap()).unwrap()).unwrap(); assert_eq!(block.block_hash(), block_hash); let scripts = t.get(3).unwrap().as_array().unwrap(); - let previous_filter_header = FilterHeader::from_hex(&t.get(4).unwrap().as_str().unwrap()).unwrap(); - let filter_content = Vec::from_hex(&t.get(5).unwrap().as_str().unwrap()).unwrap(); - let filter_header = FilterHeader::from_hex(&t.get(6).unwrap().as_str().unwrap()).unwrap(); + let previous_filter_header = FilterHeader::from_hex(t.get(4).unwrap().as_str().unwrap()).unwrap(); + let filter_content = Vec::from_hex(t.get(5).unwrap().as_str().unwrap()).unwrap(); + let filter_header = FilterHeader::from_hex(t.get(6).unwrap().as_str().unwrap()).unwrap(); let mut txmap = HashMap::new(); let mut si = scripts.iter(); @@ -576,7 +576,7 @@ mod test { for (_, script) in &txmap { let query = vec![script]; if !script.is_empty () { - assert!(filter.match_any(&block_hash, &mut query.iter() + assert!(filter.match_any(block_hash, &mut query.iter() .map(|s| s.as_bytes())).unwrap()); } } diff --git a/src/util/psbt/mod.rs b/src/util/psbt/mod.rs index c0e92701..4291178e 100644 --- a/src/util/psbt/mod.rs +++ b/src/util/psbt/mod.rs @@ -358,7 +358,7 @@ mod tests { use crate::blockdata::transaction::{Transaction, TxIn, TxOut, OutPoint}; use crate::network::constants::Network::Bitcoin; use crate::consensus::encode::{deserialize, serialize, serialize_hex}; - use crate::util::bip32::{ChildNumber, ExtendedPrivKey, ExtendedPubKey, Fingerprint, KeySource}; + use crate::util::bip32::{ChildNumber, ExtendedPrivKey, ExtendedPubKey, KeySource}; use crate::util::psbt::map::{Output, Input}; use crate::util::psbt::raw; @@ -404,7 +404,7 @@ mod tests { let mut sk: ExtendedPrivKey = ExtendedPrivKey::new_master(Bitcoin, &seed).unwrap(); - let fprint: Fingerprint = sk.fingerprint(&secp); + let fprint = sk.fingerprint(secp); let dpath: Vec = vec![ ChildNumber::from_normal_idx(0).unwrap(), @@ -419,7 +419,7 @@ mod tests { sk = sk.derive_priv(secp, &dpath).unwrap(); - let pk: ExtendedPubKey = ExtendedPubKey::from_priv(&secp, &sk); + let pk = ExtendedPubKey::from_priv(secp, &sk); hd_keypaths.insert(pk.public_key, (fprint, dpath.into())); @@ -803,7 +803,7 @@ mod tests { assert!(&psbt.inputs[0].final_script_sig.is_some()); - let redeem_script: &Script = &psbt.inputs[1].redeem_script.as_ref().unwrap(); + let redeem_script = psbt.inputs[1].redeem_script.as_ref().unwrap(); let expected_out = hex_script!("a9143545e6e33b832c47050f24d3eeb93c9c03948bc787"); assert!(redeem_script.is_v0_p2wpkh()); @@ -849,7 +849,7 @@ mod tests { assert!(&psbt.inputs[0].final_script_sig.is_none()); assert!(&psbt.inputs[1].final_script_sig.is_none()); - let redeem_script: &Script = &psbt.inputs[1].redeem_script.as_ref().unwrap(); + let redeem_script = psbt.inputs[1].redeem_script.as_ref().unwrap(); let expected_out = hex_script!("a9143545e6e33b832c47050f24d3eeb93c9c03948bc787"); assert!(redeem_script.is_v0_p2wpkh()); @@ -873,7 +873,7 @@ mod tests { assert!(&psbt.inputs[0].final_script_sig.is_none()); - let redeem_script: &Script = &psbt.inputs[0].redeem_script.as_ref().unwrap(); + let redeem_script = psbt.inputs[0].redeem_script.as_ref().unwrap(); let expected_out = hex_script!("a9146345200f68d189e1adc0df1c4d16ea8f14c0dbeb87"); assert!(redeem_script.is_v0_p2wsh()); diff --git a/src/util/sighash.rs b/src/util/sighash.rs index 0604c440..e5f51d5c 100644 --- a/src/util/sighash.rs +++ b/src/util/sighash.rs @@ -1115,11 +1115,11 @@ mod tests { }; // tests - let keypair = secp256k1::KeyPair::from_secret_key(&secp, internal_priv_key); + let keypair = secp256k1::KeyPair::from_secret_key(secp, internal_priv_key); let internal_key = XOnlyPublicKey::from_keypair(&keypair); let tweak = TapTweakHash::from_key_and_tweak(internal_key, merkle_root); let mut tweaked_keypair = keypair; - tweaked_keypair.tweak_add_assign(&secp, &tweak).unwrap(); + tweaked_keypair.tweak_add_assign(secp, &tweak).unwrap(); let mut sig_msg = Vec::new(); cache.taproot_encode_signing_data_to( &mut sig_msg, diff --git a/src/util/taproot.rs b/src/util/taproot.rs index d1c6e2fd..f830ffbe 100644 --- a/src/util/taproot.rs +++ b/src/util/taproot.rs @@ -1361,12 +1361,12 @@ mod test { if script_tree.is_null() { assert!(arr["intermediary"]["merkleRoot"].is_null()); } else { - merkle_root = Some(TapBranchHash::from_str(&arr["intermediary"]["merkleRoot"].as_str().unwrap()).unwrap()); + merkle_root = Some(TapBranchHash::from_str(arr["intermediary"]["merkleRoot"].as_str().unwrap()).unwrap()); let leaf_hashes = arr["intermediary"]["leafHashes"].as_array().unwrap(); let ctrl_blks = arr["expected"]["scriptPathControlBlocks"].as_array().unwrap(); let mut builder = TaprootBuilder::new(); let mut leaves = vec![]; - builder = process_script_trees(&script_tree, builder, &mut leaves, 0); + builder = process_script_trees(script_tree, builder, &mut leaves, 0); let spend_info = builder.finalize(secp, internal_key).unwrap(); for (i, script_ver) in leaves.iter().enumerate() { let expected_leaf_hash = leaf_hashes[i].as_str().unwrap(); @@ -1384,8 +1384,8 @@ mod test { let expected_addr = Address::from_str(arr["expected"]["bip350Address"].as_str().unwrap()).unwrap(); let tweak = TapTweakHash::from_key_and_tweak(internal_key, merkle_root); - let (output_key, _parity) = internal_key.tap_tweak(&secp, merkle_root); - let addr = Address::p2tr(&secp, internal_key, merkle_root, Network::Bitcoin); + let (output_key, _parity) = internal_key.tap_tweak(secp, merkle_root); + let addr = Address::p2tr(secp, internal_key, merkle_root, Network::Bitcoin); let spk = addr.script_pubkey(); assert_eq!(expected_output_key, output_key.to_inner());