Skip to content

Commit deb53a2

Browse files
committed
WIP Add integration tests for option_simple_close cooperative closing
Add 6 tests covering the v2 cooperative closing flow (`closing_complete` / `closing_sig`): - `test_simple_close`: Parameterized happy path (both directions) - `test_simple_close_dust_closee`: Closee has dust balance, `closer_output_only` signature used - `test_simple_close_dust_closer`: Closer has dust balance, `closee_output_only` signature used - `test_simple_close_two_sig_variants`: Both `closer_output_only` and `closer_and_closee_outputs` provided when closer >= closee - `test_simple_close_v1_fallback`: Falls back to v1 `closing_signed` when counterparty doesn't support `option_simple_close` - `test_simple_close_reconnect`: Disconnect/reconnect resets v2 negotiation state and allows protocol to restart Also adds `get_closing_sig_broadcast` helper to `functional_test_utils.rs` and `simple_close_exchange_shutdowns` helper to `shutdown_tests.rs`. Co-Authored-By: HAL 9000 Signed-off-by: Elias Rohrer <dev@tnull.de>
1 parent 3f7d75b commit deb53a2

2 files changed

Lines changed: 456 additions & 0 deletions

File tree

lightning/src/ln/functional_test_utils.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,27 @@ pub fn get_closing_signed_broadcast(
22402240
)
22412241
}
22422242

2243+
/// Extract a `ClosingSig` message and verify a `BroadcastChannelUpdate` from the closee's
2244+
/// pending message events after `handle_closing_complete`.
2245+
pub fn get_closing_sig_broadcast(node: &Node, dest_pubkey: PublicKey) -> msgs::ClosingSig {
2246+
let events = node.node.get_and_clear_pending_msg_events();
2247+
assert_eq!(events.len(), 2);
2248+
let closing_sig = match &events[0] {
2249+
MessageSendEvent::SendClosingSig { ref node_id, ref msg } => {
2250+
assert_eq!(*node_id, dest_pubkey);
2251+
msg.clone()
2252+
},
2253+
_ => panic!("Expected SendClosingSig, got {:?}", events[0]),
2254+
};
2255+
match &events[1] {
2256+
MessageSendEvent::BroadcastChannelUpdate { ref msg, .. } => {
2257+
assert_eq!(msg.contents.channel_flags & 2, 2);
2258+
},
2259+
_ => panic!("Expected BroadcastChannelUpdate, got {:?}", events[1]),
2260+
};
2261+
closing_sig
2262+
}
2263+
22432264
#[cfg(test)]
22442265
macro_rules! check_warn_msg {
22452266
($node: expr, $recipient_node_id: expr, $chan_id: expr) => {{

0 commit comments

Comments
 (0)