From 9cb953414fdad2aba130f515c908976f107d634c Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 18 Feb 2024 17:59:23 -0500 Subject: [PATCH] tests, examples: make clippy happy --- crates/daemon/keyforkd-client/src/tests.rs | 8 ++++---- crates/derive/keyfork-derive-key/src/main.rs | 2 +- crates/derive/keyfork-derive-openpgp/src/lib.rs | 2 +- crates/derive/keyfork-derive-util/src/tests.rs | 8 ++++---- .../keyfork-shard/src/bin/keyfork-shard-split-openpgp.rs | 2 +- crates/util/keyfork-entropy/src/main.rs | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/daemon/keyforkd-client/src/tests.rs b/crates/daemon/keyforkd-client/src/tests.rs index 5557d79..f6a32b8 100644 --- a/crates/daemon/keyforkd-client/src/tests.rs +++ b/crates/daemon/keyforkd-client/src/tests.rs @@ -18,7 +18,7 @@ fn secp256k1_test_suite() { let seed = seed_test.seed; run_test(&seed, move |socket_path| -> Result<(), Box> { for test in seed_test.tests { - let socket = UnixStream::connect(&socket_path).unwrap(); + let socket = UnixStream::connect(socket_path).unwrap(); let mut client = Client::new(socket); let chain = DerivationPath::from_str(test.chain).unwrap(); let chain_len = chain.len(); @@ -29,7 +29,7 @@ fn secp256k1_test_suite() { // key using an XPrv, for all but the last XPrv, which is verified after this for i in 2..chain_len { // FIXME: Keyfork will only allow one request per session - let socket = UnixStream::connect(&socket_path).unwrap(); + let socket = UnixStream::connect(socket_path).unwrap(); let mut client = Client::new(socket); let path = DerivationPath::from_str(test.chain).unwrap(); let left_path = path.inner()[..i] @@ -40,7 +40,7 @@ fn secp256k1_test_suite() { .fold(DerivationPath::default(), |p, i| p.chain_push(i.clone())); let xprv = dbg!(client.request_xprv::(&left_path)).unwrap(); let derived_xprv = xprv.derive_path(&right_path).unwrap(); - let socket = UnixStream::connect(&socket_path).unwrap(); + let socket = UnixStream::connect(socket_path).unwrap(); let mut client = Client::new(socket); let keyforkd_xprv = client.request_xprv::(&path).unwrap(); assert_eq!( @@ -73,7 +73,7 @@ fn ed25519_test_suite() { let seed = seed_test.seed; run_test(&seed, move |socket_path| { for test in seed_test.tests { - let socket = UnixStream::connect(&socket_path).unwrap(); + let socket = UnixStream::connect(socket_path).unwrap(); let mut client = Client::new(socket); let chain = DerivationPath::from_str(test.chain).unwrap(); let chain_len = chain.len(); diff --git a/crates/derive/keyfork-derive-key/src/main.rs b/crates/derive/keyfork-derive-key/src/main.rs index 21a2645..af3b236 100644 --- a/crates/derive/keyfork-derive-key/src/main.rs +++ b/crates/derive/keyfork-derive-key/src/main.rs @@ -46,7 +46,7 @@ fn run() -> Result<(), Box> { let mut client = Client::discover_socket()?; let request = DerivationRequest::new(algo, &path); let response = client.request(&request.into())?; - println!("{}", smex::encode(&DerivationResponse::try_from(response)?.data)); + println!("{}", smex::encode(DerivationResponse::try_from(response)?.data)); Ok(()) } diff --git a/crates/derive/keyfork-derive-openpgp/src/lib.rs b/crates/derive/keyfork-derive-openpgp/src/lib.rs index f77977b..6ba7755 100644 --- a/crates/derive/keyfork-derive-openpgp/src/lib.rs +++ b/crates/derive/keyfork-derive-openpgp/src/lib.rs @@ -74,7 +74,7 @@ pub fn derive(xprv: XPrv, keys: &[KeyFlags], userid: &UserID) -> Result { let expiration_date = match std::env::var("KEYFORK_OPENPGP_EXPIRE").as_mut() { Ok(var) => { let ch = var.pop(); - match (ch, u64::from_str(&var)) { + match (ch, u64::from_str(var)) { (Some(ch @ ('d' | 'm' | 'y')), Ok(expire)) => { let multiplier = match ch { 'd' => 1, diff --git a/crates/derive/keyfork-derive-util/src/tests.rs b/crates/derive/keyfork-derive-util/src/tests.rs index 3f2eba3..4872c8c 100644 --- a/crates/derive/keyfork-derive-util/src/tests.rs +++ b/crates/derive/keyfork-derive-util/src/tests.rs @@ -30,7 +30,7 @@ fn secp256k1() { } = test; // Tests for ExtendedPrivateKey - let varlen_seed = VariableLengthSeed::new(&seed); + let varlen_seed = VariableLengthSeed::new(seed); let xkey = ExtendedPrivateKey::::new(varlen_seed); let derived_key = xkey.derive_path(&chain).unwrap(); assert_eq!( @@ -51,7 +51,7 @@ fn secp256k1() { // Tests for DerivationRequest let request = DerivationRequest::new(DerivationAlgorithm::Secp256k1, &chain); - let response = request.derive_with_master_seed(&seed).unwrap(); + let response = request.derive_with_master_seed(seed).unwrap(); assert_eq!(&response.data, private_key.as_slice(), "test: {chain}"); } } @@ -76,7 +76,7 @@ fn ed25519() { } = test; // Tests for ExtendedPrivateKey - let varlen_seed = VariableLengthSeed::new(&seed); + let varlen_seed = VariableLengthSeed::new(seed); let xkey = ExtendedPrivateKey::::new(varlen_seed); let derived_key = xkey.derive_path(&chain).unwrap(); assert_eq!( @@ -97,7 +97,7 @@ fn ed25519() { // Tests for DerivationRequest let request = DerivationRequest::new(DerivationAlgorithm::Ed25519, &chain); - let response = request.derive_with_master_seed(&seed).unwrap(); + let response = request.derive_with_master_seed(seed).unwrap(); assert_eq!(&response.data, private_key.as_slice(), "test: {chain}"); } } diff --git a/crates/keyfork-shard/src/bin/keyfork-shard-split-openpgp.rs b/crates/keyfork-shard/src/bin/keyfork-shard-split-openpgp.rs index 2f12e58..29d6f0a 100644 --- a/crates/keyfork-shard/src/bin/keyfork-shard-split-openpgp.rs +++ b/crates/keyfork-shard/src/bin/keyfork-shard-split-openpgp.rs @@ -69,7 +69,7 @@ fn run() -> Result<()> { let Some(line) = stdin().lines().next() else { return Err(Error::Input.into()); }; - smex::decode(&line?)? + smex::decode(line?)? }; split(threshold, cert_list, &input, std::io::stdout())?; diff --git a/crates/util/keyfork-entropy/src/main.rs b/crates/util/keyfork-entropy/src/main.rs index b2f97b3..4ffbb98 100644 --- a/crates/util/keyfork-entropy/src/main.rs +++ b/crates/util/keyfork-entropy/src/main.rs @@ -16,7 +16,7 @@ fn main() -> Result<(), Box> { ); let entropy = keyfork_entropy::generate_entropy_of_size(bit_size / 8)?; - println!("{}", smex::encode(&entropy)); + println!("{}", smex::encode(entropy)); Ok(()) }