Skip to content

Commit 7b77771

Browse files
committed
Flush messages after test payments
After we've verified that payments will succeed, flush the messages so that the next test starts with all the message queues empty.
1 parent 3653e5e commit 7b77771

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,9 +1494,28 @@ pub fn do_test<Out: Output>(data: &[u8], underlying_out: Out, anchors: bool) {
14941494
assert!(
14951495
send_payment(&nodes[0], &nodes[1], chan_a, 10_000_000, &mut payment_id, &mut payment_idx) ||
14961496
send_payment(&nodes[1], &nodes[0], chan_a, 10_000_000, &mut payment_id, &mut payment_idx));
1497+
out.locked_write(format!("Successfully sent a payment between node 0 and node 1.\n").as_bytes());
1498+
14971499
assert!(
14981500
send_payment(&nodes[1], &nodes[2], chan_b, 10_000_000, &mut payment_id, &mut payment_idx) ||
14991501
send_payment(&nodes[2], &nodes[1], chan_b, 10_000_000, &mut payment_id, &mut payment_idx));
1502+
out.locked_write(format!("Successfully sent a payment between node 1 and node 2.\n").as_bytes());
1503+
1504+
out.locked_write(format!("Flushing pending messages.\n").as_bytes());
1505+
for i in 0..std::usize::MAX {
1506+
if i == 100 { panic!("It may take may iterations to settle the state, but it should not take forever"); }
1507+
1508+
// Then, make sure any current forwards make their way to their destination
1509+
if process_msg_events!(0, false, ProcessMessages::AllMessages) { continue; }
1510+
if process_msg_events!(1, false, ProcessMessages::AllMessages) { continue; }
1511+
if process_msg_events!(2, false, ProcessMessages::AllMessages) { continue; }
1512+
// ...making sure any pending PendingHTLCsForwardable events are handled and
1513+
// payments claimed.
1514+
if process_events!(0, false) { continue; }
1515+
if process_events!(1, false) { continue; }
1516+
if process_events!(2, false) { continue; }
1517+
break;
1518+
}
15001519

15011520
last_htlc_clear_fee_a = fee_est_a.ret_val.load(atomic::Ordering::Acquire);
15021521
last_htlc_clear_fee_b = fee_est_b.ret_val.load(atomic::Ordering::Acquire);

0 commit comments

Comments
 (0)