keyfork-derive-util: make clippy happy
This commit is contained in:
parent
6b61279656
commit
dc1e192b67
|
@ -90,7 +90,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn fails_on_high_index() {
|
fn fails_on_high_index() {
|
||||||
DerivationIndex::new(0x80000001, false).unwrap();
|
DerivationIndex::new(0x8000_0001, false).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -100,19 +100,19 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn misc_values() -> Result<()> {
|
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(0x2, false)?.0, 2);
|
||||||
assert_eq!(DerivationIndex::new(0x00ABCDEF, true)?.0, 0x80ABCDEF);
|
assert_eq!(DerivationIndex::new(0x00AB_CDEF, true)?.0, 0x80AB_CDEF);
|
||||||
assert_eq!(DerivationIndex::new(0x00ABCDEF, false)?.0, 0x00ABCDEF);
|
assert_eq!(DerivationIndex::new(0x00AB_CDEF, false)?.0, 0x00AB_CDEF);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn from_str() -> Result<()> {
|
fn from_str() -> Result<()> {
|
||||||
assert_eq!(DerivationIndex::from_str("100000")?.0, 100000);
|
assert_eq!(DerivationIndex::from_str("100000")?.0, 100_000);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DerivationIndex::from_str("100000'")?.0,
|
DerivationIndex::from_str("100000'")?.0,
|
||||||
(0b1 << 31) + 100000
|
(0b1 << 31) + 100_000
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,6 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn from_str_fails_on_high_index() {
|
fn from_str_fails_on_high_index() {
|
||||||
DerivationIndex::from_str(&0x80000001u32.to_string()).unwrap();
|
DerivationIndex::from_str(&0x8000_0001u32.to_string()).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// Because all algorithms make use of wildcard matching
|
||||||
|
#![allow(clippy::match_wildcard_for_single_variants)]
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
extended_key::private_key::Error as XPrvError, DerivationPath, ExtendedPrivateKey, PrivateKey,
|
extended_key::private_key::Error as XPrvError, DerivationPath, ExtendedPrivateKey, PrivateKey,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(clippy::implicit_clone)]
|
||||||
|
|
||||||
use crate::{request::*, *};
|
use crate::{request::*, *};
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
@ -48,7 +50,7 @@ fn secp256k1() {
|
||||||
|
|
||||||
// Tests for DerivationRequest
|
// Tests for DerivationRequest
|
||||||
let request = DerivationRequest::new(DerivationAlgorithm::Secp256k1, &chain);
|
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}");
|
assert_eq!(&response.data, private_key, "test: {chain}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +121,7 @@ fn panics_at_depth() {
|
||||||
|
|
||||||
let seed = hex!("000102030405060708090a0b0c0d0e0f");
|
let seed = hex!("000102030405060708090a0b0c0d0e0f");
|
||||||
let mut xkey = ExtendedPrivateKey::<SigningKey>::new(seed).unwrap();
|
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
|
xkey = xkey
|
||||||
.derive_child(&DerivationIndex::new(i, true).unwrap())
|
.derive_child(&DerivationIndex::new(i, true).unwrap())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Reference in New Issue