]> git.bitcoin.ninja Git - rust-lightning/commitdiff
`rustfmt`: `fuzz/src/peer_crypt.rs`
authorElias Rohrer <dev@tnull.de>
Thu, 6 Jun 2024 11:11:19 +0000 (13:11 +0200)
committerElias Rohrer <dev@tnull.de>
Fri, 7 Jun 2024 18:42:36 +0000 (20:42 +0200)
fuzz/src/peer_crypt.rs
rustfmt_excluded_files

index 41d8c0936060868a97df54711f725e397ea3a35d..b01aa02400b6c65a135aa5d5a454323e664eabbe 100644 (file)
@@ -7,33 +7,30 @@
 // You may not use this file except in accordance with one or both of these
 // licenses.
 
-use lightning::ln::peer_channel_encryptor::{PeerChannelEncryptor, MessageBuf};
+use lightning::ln::peer_channel_encryptor::{MessageBuf, PeerChannelEncryptor};
 use lightning::util::test_utils::TestNodeSigner;
 
-use bitcoin::secp256k1::{Secp256k1, PublicKey, SecretKey};
+use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
 
 use crate::utils::test_logger;
 
 #[inline]
 fn slice_to_be16(v: &[u8]) -> u16 {
-       ((v[0] as u16) << 8*1) |
-       ((v[1] as u16) << 8*0)
+       ((v[0] as u16) << 8 * 1) | ((v[1] as u16) << 8 * 0)
 }
 
 #[inline]
 pub fn do_test(data: &[u8]) {
        let mut read_pos = 0;
        macro_rules! get_slice {
-               ($len: expr) => {
-                       {
-                               let slice_len = $len as usize;
-                               if data.len() < read_pos + slice_len {
-                                       return;
-                               }
-                               read_pos += slice_len;
-                               &data[read_pos - slice_len..read_pos]
+               ($len: expr) => {{
+                       let slice_len = $len as usize;
+                       if data.len() < read_pos + slice_len {
+                               return;
                        }
-               }
+                       read_pos += slice_len;
+                       &data[read_pos - slice_len..read_pos]
+               }};
        }
 
        let secp_ctx = Secp256k1::signing_only();
@@ -63,7 +60,12 @@ pub fn do_test(data: &[u8]) {
                crypter
        } else {
                let mut crypter = PeerChannelEncryptor::new_inbound(&&node_signer);
-               match crypter.process_act_one_with_keys(get_slice!(50), &&node_signer, ephemeral_key, &secp_ctx) {
+               match crypter.process_act_one_with_keys(
+                       get_slice!(50),
+                       &&node_signer,
+                       ephemeral_key,
+                       &secp_ctx,
+               ) {
                        Ok(_) => {},
                        Err(_) => return,
                }
@@ -77,9 +79,11 @@ pub fn do_test(data: &[u8]) {
        let mut buf = [0; 65536 + 16];
        loop {
                if get_slice!(1)[0] == 0 {
-                       crypter.encrypt_buffer(MessageBuf::from_encoded(&get_slice!(slice_to_be16(get_slice!(2)))));
+                       crypter.encrypt_buffer(MessageBuf::from_encoded(&get_slice!(slice_to_be16(
+                               get_slice!(2)
+                       ))));
                } else {
-                       let len = match crypter.decrypt_length_header(get_slice!(16+2)) {
+                       let len = match crypter.decrypt_length_header(get_slice!(16 + 2)) {
                                Ok(len) => len,
                                Err(_) => return,
                        };
index 1c125a11a29c941a640bd633ca5e8626842d1952..c627a3c6d6f56020166d6f91acc3cee58c30b9b0 100644 (file)
@@ -1,7 +1,6 @@
 ./bench/benches/bench.rs
 ./fuzz/src/chanmon_consistency.rs
 ./fuzz/src/full_stack.rs
-./fuzz/src/peer_crypt.rs
 ./fuzz/src/process_network_graph.rs
 ./fuzz/src/refund_deser.rs
 ./fuzz/src/router.rs