Skip to content

Commit

Permalink
Flush messages after test payments
Browse files Browse the repository at this point in the history
After we've verified that payments will succeed, flush the messages so that
the next test starts with all the message queues empty.
  • Loading branch information
waterson committed Jan 11, 2024
1 parent 4d6d31f commit c11e916
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions fuzz/src/chanmon_consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1494,9 +1494,28 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
assert!(
send_payment(&nodes[0], &nodes[1], chan_a, 10_000_000, &mut payment_id, &mut payment_idx) ||
send_payment(&nodes[1], &nodes[0], chan_a, 10_000_000, &mut payment_id, &mut payment_idx));
out.locked_write(format!("Successfully sent a payment between node 0 and node 1.\n").as_bytes());

assert!(
send_payment(&nodes[1], &nodes[2], chan_b, 10_000_000, &mut payment_id, &mut payment_idx) ||
send_payment(&nodes[2], &nodes[1], chan_b, 10_000_000, &mut payment_id, &mut payment_idx));
out.locked_write(format!("Successfully sent a payment between node 1 and node 2.\n").as_bytes());

out.locked_write(format!("Flushing pending messages.\n").as_bytes());
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"); }

// Then, make sure any current forwards make their way to their destination
if process_msg_events!(0, false, ProcessMessages::AllMessages) { continue; }
if process_msg_events!(1, false, ProcessMessages::AllMessages) { continue; }
if process_msg_events!(2, false, ProcessMessages::AllMessages) { continue; }
// ...making sure any pending PendingHTLCsForwardable events are handled and
// payments claimed.
if process_events!(0, false) { continue; }
if process_events!(1, false) { continue; }
if process_events!(2, false) { continue; }
break;
}

last_htlc_clear_fee_a = fee_est_a.ret_val.load(atomic::Ordering::Acquire);
last_htlc_clear_fee_b = fee_est_b.ret_val.load(atomic::Ordering::Acquire);
Expand Down

0 comments on commit c11e916

Please sign in to comment.