Hoist chanmon process_all_events macro
What changed, and why it matters
This commit is a simple code cleanup inside a fuzz test file. It moves a helper macro (a reusable chunk of code) to a higher scope so that more parts of the test can use it later. No production code, no security fix, and no behavior change.
No action needed. This is a non-security refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change hoists the process_all_events! macro definition out of a single match arm in fuzz/src/chanmon_consistency.rs to the enclosing function scope. The macro body is identical; only its visibility/location changes. This is a pure refactoring to support future extraction of payment helpers. It affects only fuzzing infrastructure, not the LDK library or any runtime logic.
Changed components
fuzz/src/chanmon_consistency.rsInspect captured patch +51 / −51
diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs
index 7030f4e..1f955a1 100644
--- a/fuzz/src/chanmon_consistency.rs
+++ b/fuzz/src/chanmon_consistency.rs
@@ -2450,6 +2450,57 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(data: &[u8], out: Out) {
}
};
+ macro_rules! process_all_events {
+ () => { {
+ let mut last_pass_no_updates = false;
+ for i in 0..std::usize::MAX {
+ if i == 100 {
+ panic!("It may take may iterations to settle the state, but it should not take forever");
+ }
+ // Next, make sure no monitor updates are pending
+ ab_link.complete_all_monitor_updates(&nodes);
+ bc_link.complete_all_monitor_updates(&nodes);
+ // Then, make sure any current forwards make their way to their destination
+ if process_msg_events!(0, false, ProcessMessages::AllMessages) {
+ last_pass_no_updates = false;
+ continue;
+ }
+ if process_msg_events!(1, false, ProcessMessages::AllMessages) {
+ last_pass_no_updates = false;
+ continue;
+ }
+ if process_msg_events!(2, false, ProcessMessages::AllMessages) {
+ last_pass_no_updates = false;
+ continue;
+ }
+ // ...making sure any payments are claimed.
+ if process_events!(0, false) {
+ last_pass_no_updates = false;
+ continue;
+ }
+ if process_events!(1, false) {
+ last_pass_no_updates = false;
+ continue;
+ }
+ if process_events!(2, false) {
+ last_pass_no_updates = false;
+ continue;
+ }
+ if last_pass_no_updates {
+ // In some cases, we may generate a message to send in
+ // `process_msg_events`, but block sending until
+ // `complete_all_monitor_updates` gets called on the next
+ // iteration.
+ //
+ // Thus, we only exit if we manage two iterations with no messages
+ // or events to process.
+ break;
+ }
+ last_pass_no_updates = true;
+ }
+ } };
+ }
+
let v = get_slice!(1)[0];
out.locked_write(format!("READ A BYTE! HANDLING INPUT {:x}...........\n", v).as_bytes());
match v {
@@ -2825,57 +2876,6 @@ pub fn do_test<Out: Output + MaybeSend + MaybeSync>(data: &[u8], out: Out) {
nodes[1].signer_unblocked(None);
nodes[2].signer_unblocked(None);
- macro_rules! process_all_events {
- () => { {
- let mut last_pass_no_updates = false;
- for i in 0..std::usize::MAX {
- if i == 100 {
- panic!("It may take may iterations to settle the state, but it should not take forever");
- }
- // Next, make sure no monitor updates are pending
- ab_link.complete_all_monitor_updates(&nodes);
- bc_link.complete_all_monitor_updates(&nodes);
- // Then, make sure any current forwards make their way to their destination
- if process_msg_events!(0, false, ProcessMessages::AllMessages) {
- last_pass_no_updates = false;
- continue;
- }
- if process_msg_events!(1, false, ProcessMessages::AllMessages) {
- last_pass_no_updates = false;
- continue;
- }
- if process_msg_events!(2, false, ProcessMessages::AllMessages) {
- last_pass_no_updates = false;
- continue;
- }
- // ...making sure any payments are claimed.
- if process_events!(0, false) {
- last_pass_no_updates = false;
- continue;
- }
- if process_events!(1, false) {
- last_pass_no_updates = false;
- continue;
- }
- if process_events!(2, false) {
- last_pass_no_updates = false;
- continue;
- }
- if last_pass_no_updates {
- // In some cases, we may generate a message to send in
- // `process_msg_events`, but block sending until
- // `complete_all_monitor_updates` gets called on the next
- // iteration.
- //
- // Thus, we only exit if we manage two iterations with no messages
- // or events to process.
- break;
- }
- last_pass_no_updates = true;
- }
- } };
- }
-
process_all_events!();
// Since MPP payments are supported, we wait until we fully settle the state of all
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.