From f0edabbea870eda401937e95eb46a229576ac11b Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 7 May 2026 11:03:47 +0200 Subject: [PATCH] Add chanmon stuck HTLC invariant Assert that channel HTLC sets are empty after harness quiescence. --- fuzz/src/chanmon_consistency.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs index 8a90dc93e97..c37808d18ee 100644 --- a/fuzz/src/chanmon_consistency.rs +++ b/fuzz/src/chanmon_consistency.rs @@ -2726,6 +2726,23 @@ impl<'a, Out: Output + MaybeSend + MaybeSync> Harness<'a, Out> { // PaymentSent event at the sender. self.payments.assert_claims_reported(); + // All HTLCs should have been claimed or failed once we reach quiescence. + for (idx, node) in self.nodes.iter().enumerate() { + for chan in node.list_channels() { + assert!( + chan.pending_inbound_htlcs.is_empty() && chan.pending_outbound_htlcs.is_empty(), + "Node {} channel {:?} has stuck HTLCs after settling all state: \ + {} inbound {:?}, {} outbound {:?}", + idx, + chan.channel_id, + chan.pending_inbound_htlcs.len(), + chan.pending_inbound_htlcs, + chan.pending_outbound_htlcs.len(), + chan.pending_outbound_htlcs + ); + } + } + // Finally, make sure that at least one end of each channel can make a substantial payment. let chan_ab_ids = self.ab_link.channel_ids().clone(); let chan_bc_ids = self.bc_link.channel_ids().clone();