From dc1e192b6740a04a11c9bd716d3504a38544c2a0 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 6 Jan 2024 23:18:52 -0500 Subject: [PATCH] keyfork-derive-util: make clippy happy --- keyfork-derive-util/src/index.rs | 14 +++++++------- keyfork-derive-util/src/request.rs | 3 +++ keyfork-derive-util/src/tests.rs | 6 ++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/keyfork-derive-util/src/index.rs b/keyfork-derive-util/src/index.rs index 15254f9..75a75b6 100644 --- a/keyfork-derive-util/src/index.rs +++ b/keyfork-derive-util/src/index.rs @@ -90,7 +90,7 @@ mod tests { #[test] #[should_panic] fn fails_on_high_index() { - DerivationIndex::new(0x80000001, false).unwrap(); + DerivationIndex::new(0x8000_0001, false).unwrap(); } #[test] @@ -100,19 +100,19 @@ mod tests { #[test] fn misc_values() -> Result<()> { - assert_eq!(DerivationIndex::new(0x80000000 - 1, true)?.0, u32::MAX); + assert_eq!(DerivationIndex::new(0x8000_0000 - 1, true)?.0, u32::MAX); assert_eq!(DerivationIndex::new(0x2, false)?.0, 2); - assert_eq!(DerivationIndex::new(0x00ABCDEF, true)?.0, 0x80ABCDEF); - assert_eq!(DerivationIndex::new(0x00ABCDEF, false)?.0, 0x00ABCDEF); + assert_eq!(DerivationIndex::new(0x00AB_CDEF, true)?.0, 0x80AB_CDEF); + assert_eq!(DerivationIndex::new(0x00AB_CDEF, false)?.0, 0x00AB_CDEF); Ok(()) } #[test] fn from_str() -> Result<()> { - assert_eq!(DerivationIndex::from_str("100000")?.0, 100000); + assert_eq!(DerivationIndex::from_str("100000")?.0, 100_000); assert_eq!( DerivationIndex::from_str("100000'")?.0, - (0b1 << 31) + 100000 + (0b1 << 31) + 100_000 ); Ok(()) } @@ -136,6 +136,6 @@ mod tests { #[test] #[should_panic] fn from_str_fails_on_high_index() { - DerivationIndex::from_str(&0x80000001u32.to_string()).unwrap(); + DerivationIndex::from_str(&0x8000_0001u32.to_string()).unwrap(); } } diff --git a/keyfork-derive-util/src/request.rs b/keyfork-derive-util/src/request.rs index d26e03e..a96f793 100644 --- a/keyfork-derive-util/src/request.rs +++ b/keyfork-derive-util/src/request.rs @@ -1,3 +1,6 @@ +// Because all algorithms make use of wildcard matching +#![allow(clippy::match_wildcard_for_single_variants)] + use crate::{ extended_key::private_key::Error as XPrvError, DerivationPath, ExtendedPrivateKey, PrivateKey, }; diff --git a/keyfork-derive-util/src/tests.rs b/keyfork-derive-util/src/tests.rs index 82616ac..f4238e3 100644 --- a/keyfork-derive-util/src/tests.rs +++ b/keyfork-derive-util/src/tests.rs @@ -1,3 +1,5 @@ +#![allow(clippy::implicit_clone)] + use crate::{request::*, *}; use hex_literal::hex; use std::str::FromStr; @@ -48,7 +50,7 @@ fn secp256k1() { // Tests for DerivationRequest let request = DerivationRequest::new(DerivationAlgorithm::Secp256k1, &chain); - let response = request.derive_with_master_seed(seed.to_vec()).unwrap(); + let response = request.derive_with_master_seed(seed.clone()).unwrap(); assert_eq!(&response.data, private_key, "test: {chain}"); } } @@ -119,7 +121,7 @@ fn panics_at_depth() { let seed = hex!("000102030405060708090a0b0c0d0e0f"); let mut xkey = ExtendedPrivateKey::::new(seed).unwrap(); - for i in 0..u32::from(u8::MAX) + 1 { + for i in 0..=u32::from(u8::MAX) { xkey = xkey .derive_child(&DerivationIndex::new(i, true).unwrap()) .unwrap();