From 999ac450bba2a45cf48c297c03e1d0de013802e6 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 7 Jun 2022 14:31:03 +1000 Subject: [PATCH] Do not use assert_eq with literal bool Clippy emits: warning: used `assert_eq!` with a literal bool Use `assert!` instead of `assert_eq!(foo, true)`. --- src/blockdata/script.rs | 14 +++++++------- src/network/message.rs | 4 ++-- src/network/message_network.rs | 2 +- src/network/stream_reader.rs | 2 +- src/util/key.rs | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/blockdata/script.rs b/src/blockdata/script.rs index 00597180..ab141fcf 100644 --- a/src/blockdata/script.rs +++ b/src/blockdata/script.rs @@ -1329,18 +1329,18 @@ mod test { #[test] fn provably_unspendable_test() { // p2pk - assert_eq!(hex_script!("410446ef0102d1ec5240f0d061a4246c1bdef63fc3dbab7733052fbbf0ecd8f41fc26bf049ebb4f9527f374280259e7cfa99c48b0e3f39c51347a19a5819651503a5ac").is_provably_unspendable(), false); - assert_eq!(hex_script!("4104ea1feff861b51fe3f5f8a3b12d0f4712db80e919548a80839fc47c6a21e66d957e9c5d8cd108c7a2d2324bad71f9904ac0ae7336507d785b17a2c115e427a32fac").is_provably_unspendable(), false); + assert!(!hex_script!("410446ef0102d1ec5240f0d061a4246c1bdef63fc3dbab7733052fbbf0ecd8f41fc26bf049ebb4f9527f374280259e7cfa99c48b0e3f39c51347a19a5819651503a5ac").is_provably_unspendable()); + assert!(!hex_script!("4104ea1feff861b51fe3f5f8a3b12d0f4712db80e919548a80839fc47c6a21e66d957e9c5d8cd108c7a2d2324bad71f9904ac0ae7336507d785b17a2c115e427a32fac").is_provably_unspendable()); // p2pkhash - assert_eq!(hex_script!("76a914ee61d57ab51b9d212335b1dba62794ac20d2bcf988ac").is_provably_unspendable(), false); - assert_eq!(hex_script!("6aa9149eb21980dc9d413d8eac27314938b9da920ee53e87").is_provably_unspendable(), true); + assert!(!hex_script!("76a914ee61d57ab51b9d212335b1dba62794ac20d2bcf988ac").is_provably_unspendable()); + assert!(hex_script!("6aa9149eb21980dc9d413d8eac27314938b9da920ee53e87").is_provably_unspendable()); } #[test] fn op_return_test() { - assert_eq!(hex_script!("6aa9149eb21980dc9d413d8eac27314938b9da920ee53e87").is_op_return(), true); - assert_eq!(hex_script!("76a914ee61d57ab51b9d212335b1dba62794ac20d2bcf988ac").is_op_return(), false); - assert_eq!(hex_script!("").is_op_return(), false); + assert!(hex_script!("6aa9149eb21980dc9d413d8eac27314938b9da920ee53e87").is_op_return()); + assert!(!hex_script!("76a914ee61d57ab51b9d212335b1dba62794ac20d2bcf988ac").is_op_return()); + assert!(!hex_script!("").is_op_return()); } #[test] diff --git a/src/network/message.rs b/src/network/message.rs index eada0d26..7d095c40 100644 --- a/src/network/message.rs +++ b/src/network/message.rs @@ -597,7 +597,7 @@ mod test { assert_eq!(version_msg.nonce, 13952548347456104954); assert_eq!(version_msg.user_agent, "/Satoshi:0.17.1/"); assert_eq!(version_msg.start_height, 560275); - assert_eq!(version_msg.relay, true); + assert!(version_msg.relay); } else { panic!("Wrong message type"); } @@ -634,7 +634,7 @@ mod test { assert_eq!(version_msg.nonce, 13952548347456104954); assert_eq!(version_msg.user_agent, "/Satoshi:0.17.1/"); assert_eq!(version_msg.start_height, 560275); - assert_eq!(version_msg.relay, true); + assert!(version_msg.relay); } else { panic!("Wrong message type"); } diff --git a/src/network/message_network.rs b/src/network/message_network.rs index bd9a7720..0e884c97 100644 --- a/src/network/message_network.rs +++ b/src/network/message_network.rs @@ -170,7 +170,7 @@ mod tests { assert_eq!(real_decode.nonce, 16735069437859780935); assert_eq!(real_decode.user_agent, "/Satoshi:0.9.99/".to_string()); assert_eq!(real_decode.start_height, 302892); - assert_eq!(real_decode.relay, true); + assert!(real_decode.relay); assert_eq!(serialize(&real_decode), from_sat); } diff --git a/src/network/stream_reader.rs b/src/network/stream_reader.rs index e3d5b81d..e1f69c23 100644 --- a/src/network/stream_reader.rs +++ b/src/network/stream_reader.rs @@ -139,7 +139,7 @@ mod test { assert_eq!(version_msg.nonce, 13952548347456104954); assert_eq!(version_msg.user_agent, "/Satoshi:0.17.1/"); assert_eq!(version_msg.start_height, 560275); - assert_eq!(version_msg.relay, true); + assert!(version_msg.relay); } else { panic!("Wrong message type: expected VersionMessage"); } diff --git a/src/util/key.rs b/src/util/key.rs index 55ca92a7..3ea21066 100644 --- a/src/util/key.rs +++ b/src/util/key.rs @@ -497,7 +497,7 @@ mod tests { // testnet compressed let sk = PrivateKey::from_wif("cVt4o7BGAig1UXywgGSmARhxMdzP5qvQsxKkSsc1XEkw3tDTQFpy").unwrap(); assert_eq!(sk.network, Testnet); - assert_eq!(sk.compressed, true); + assert!(sk.compressed); assert_eq!(&sk.to_wif(), "cVt4o7BGAig1UXywgGSmARhxMdzP5qvQsxKkSsc1XEkw3tDTQFpy"); let secp = Secp256k1::new(); @@ -513,12 +513,12 @@ mod tests { // mainnet uncompressed let sk = PrivateKey::from_wif("5JYkZjmN7PVMjJUfJWfRFwtuXTGB439XV6faajeHPAM9Z2PT2R3").unwrap(); assert_eq!(sk.network, Bitcoin); - assert_eq!(sk.compressed, false); + assert!(!sk.compressed); assert_eq!(&sk.to_wif(), "5JYkZjmN7PVMjJUfJWfRFwtuXTGB439XV6faajeHPAM9Z2PT2R3"); let secp = Secp256k1::new(); let mut pk = sk.public_key(&secp); - assert_eq!(pk.compressed, false); + assert!(!pk.compressed); assert_eq!(&pk.to_string(), "042e58afe51f9ed8ad3cc7897f634d881fdbe49a81564629ded8156bebd2ffd1af191923a2964c177f5b5923ae500fca49e99492d534aa3759d6b25a8bc971b133"); assert_eq!(pk, PublicKey::from_str("042e58afe51f9ed8ad3cc7897f634d881fdbe49a81564629ded8156bebd2ffd1af191923a2964c177f5b5923ae500fca49e99492d534aa3759d6b25a8bc971b133").unwrap()); let addr = Address::p2pkh(&pk, sk.network);