keyfork-derive-util: make clippy happy

This commit is contained in:
Ryan Heywood 2024-01-06 23:18:52 -05:00
parent 6b61279656
commit dc1e192b67
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
3 changed files with 14 additions and 9 deletions

View File

@ -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();
}
}

View File

@ -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,
};

View File

@ -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::<SigningKey>::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();