Skip to content

Commit c22b415

Browse files
authored
Merge pull request #894 from tankyleo/2026-04-full-cycle-mutual-close-coverage
Make sure the mutual close gets confirmed in `do_channel_full_cycle`
2 parents f7d6cf1 + 1eb486d commit c22b415

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tests/common/mod.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,49 @@ pub(crate) async fn do_channel_full_cycle<E: ElectrumApi>(
15431543
generate_blocks_and_wait(&bitcoind, electrsd, 5).await;
15441544
node_a.sync_wallets().unwrap();
15451545
node_b.sync_wallets().unwrap();
1546+
} else {
1547+
assert_eq!(node_a.list_balances().lightning_balances.len(), 1);
1548+
assert!(node_a.list_balances().pending_balances_from_channel_closures.is_empty());
1549+
let node_a_blocks_to_go = match node_a.list_balances().lightning_balances[0] {
1550+
LightningBalance::ClaimableAwaitingConfirmations {
1551+
counterparty_node_id,
1552+
confirmation_height,
1553+
..
1554+
} => {
1555+
assert_eq!(counterparty_node_id, node_b.node_id());
1556+
let cur_height = node_a.status().current_best_block.height;
1557+
let blocks_to_go = confirmation_height - cur_height;
1558+
blocks_to_go
1559+
},
1560+
_ => panic!("Unexpected balance state!"),
1561+
};
1562+
1563+
assert_eq!(node_b.list_balances().lightning_balances.len(), 1);
1564+
assert!(node_b.list_balances().pending_balances_from_channel_closures.is_empty());
1565+
let node_b_blocks_to_go = match node_b.list_balances().lightning_balances[0] {
1566+
LightningBalance::ClaimableAwaitingConfirmations {
1567+
counterparty_node_id,
1568+
confirmation_height,
1569+
..
1570+
} => {
1571+
assert_eq!(counterparty_node_id, node_a.node_id());
1572+
let cur_height = node_b.status().current_best_block.height;
1573+
let blocks_to_go = confirmation_height - cur_height;
1574+
blocks_to_go
1575+
},
1576+
_ => panic!("Unexpected balance state!"),
1577+
};
1578+
1579+
assert_eq!(node_a_blocks_to_go, node_b_blocks_to_go);
1580+
1581+
generate_blocks_and_wait(&bitcoind, electrsd, node_a_blocks_to_go as usize).await;
1582+
node_a.sync_wallets().unwrap();
1583+
node_b.sync_wallets().unwrap();
1584+
1585+
assert!(node_a.list_balances().lightning_balances.is_empty());
1586+
assert!(node_a.list_balances().pending_balances_from_channel_closures.is_empty());
1587+
assert!(node_b.list_balances().lightning_balances.is_empty());
1588+
assert!(node_b.list_balances().pending_balances_from_channel_closures.is_empty());
15461589
}
15471590

15481591
let sum_of_all_payments_sat = (push_msat

0 commit comments

Comments
 (0)