lightningdevkit / rust-lightning

A highly modular Bitcoin Lightning library written in Rust. It's rust-lightning, not Rusty's Lightning!
Other
1.15k stars 363 forks source link

`rustfmt`: Reformat the `fuzz` dir – the easy part #3111

Closed tnull closed 3 months ago

tnull commented 3 months ago

As suggested here, we split out the easy part from #3102 to have it land fast and reduce the risk of potential rebases becoming necessary.

codecov-commenter commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 89.85%. Comparing base (88124a9) to head (99409fb).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3111 +/- ## ========================================== + Coverage 89.84% 89.85% +0.01% ========================================== Files 119 119 Lines 97843 97843 Branches 97843 97843 ========================================== + Hits 87906 87921 +15 + Misses 7368 7352 -16 - Partials 2569 2570 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

tnull commented 3 months ago

Fixed.

tnull commented 3 months ago

Force pushed with the following changes:

> git diff-tree -U2 b5dd23920 a8622c98b
diff --git a/fuzz/src/router.rs b/fuzz/src/router.rs
index f62461df4..a40026821 100644
--- a/fuzz/src/router.rs
+++ b/fuzz/src/router.rs
@@ -208,12 +208,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
                                        for _ in 0..count {
                                                scid += 1;
-                                               let (rnid, _) = node_pks
-                                                       .iter()
-                                                       .skip(
-                                                               u16::from_be_bytes(get_slice!(2).try_into().unwrap()) as usize
-                                                                       % node_pks.len(),
-                                                       )
-                                                       .next()
-                                                       .unwrap();
+                                               let skip = u16::from_be_bytes(get_slice!(2).try_into().unwrap()) as usize
+                                                       % node_pks.len();
+                                               let (rnid, _) = node_pks.iter().skip(skip).next().unwrap();
                                                let capacity = u64::from_be_bytes(get_slice!(8).try_into().unwrap());
                                                $first_hops_vec.push(ChannelDetails {
@@ -272,9 +267,6 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
                        for _ in 0..count {
                                scid += 1;
-                               let (rnid, _) = node_pks
-                                       .iter()
-                                       .skip(slice_to_be16(get_slice!(2)) as usize % node_pks.len())
-                                       .next()
-                                       .unwrap();
+                               let skip = slice_to_be16(get_slice!(2)) as usize % node_pks.len();
+                               let (rnid, _) = node_pks.iter().skip(skip).next().unwrap();
                                $last_hops.push(RouteHint(vec![RouteHintHop {
                                        src_node_id: *rnid,
TheBlueMatt commented 3 months ago

3080 should go first, i think.

tnull commented 3 months ago

3080 should go first, i think.

Fine by me, although IIUC there should barely be any conflicts as this doesn't interfere with the full_stack/chanmon_consistency changes.

tnull commented 3 months ago

Rebased to resolve minor conflicts after #3080 landed.