Skip to content

Commit 1485a85

Browse files
author
Antoine Riard
committed
Add test_static_output_closing_tx
1 parent cf31c88 commit 1485a85

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/ln/channelmanager.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3696,7 +3696,7 @@ mod tests {
36963696
}
36973697
}
36983698

3699-
fn close_channel(outbound_node: &Node, inbound_node: &Node, channel_id: &[u8; 32], funding_tx: Transaction, close_inbound_first: bool) -> (msgs::ChannelUpdate, msgs::ChannelUpdate) {
3699+
fn close_channel(outbound_node: &Node, inbound_node: &Node, channel_id: &[u8; 32], funding_tx: Transaction, close_inbound_first: bool) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, Transaction) {
37003700
let (node_a, broadcaster_a, struct_a) = if close_inbound_first { (&inbound_node.node, &inbound_node.tx_broadcaster, inbound_node) } else { (&outbound_node.node, &outbound_node.tx_broadcaster, outbound_node) };
37013701
let (node_b, broadcaster_b) = if close_inbound_first { (&outbound_node.node, &outbound_node.tx_broadcaster) } else { (&inbound_node.node, &inbound_node.tx_broadcaster) };
37023702
let (tx_a, tx_b);
@@ -3759,7 +3759,7 @@ mod tests {
37593759
assert_eq!(tx_a, tx_b);
37603760
check_spends!(tx_a, funding_tx);
37613761

3762-
(as_update, bs_update)
3762+
(as_update, bs_update, tx_a)
37633763
}
37643764

37653765
struct SendEvent {
@@ -7997,4 +7997,22 @@ mod tests {
79977997
check_spends!(spend_txn[0], local_txn[0].clone());
79987998
check_spends!(spend_txn[1], node_txn[0].clone());
79997999
}
8000+
8001+
#[test]
8002+
fn test_static_output_closing_tx() {
8003+
let nodes = create_network(2);
8004+
8005+
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
8006+
8007+
send_payment(&nodes[0], &vec!(&nodes[1])[..], 8000000);
8008+
let closing_tx = close_channel(&nodes[0], &nodes[1], &chan.2, chan.3, true).2;
8009+
8010+
let events = nodes[0].node.get_and_clear_pending_events();
8011+
let spend_tx = check_static_output!(events, nodes, 0, 0, 2, 0);
8012+
check_spends!(spend_tx, closing_tx.clone());
8013+
8014+
let events = nodes[1].node.get_and_clear_pending_events();
8015+
let spend_tx = check_static_output!(events, nodes, 0, 0, 2, 1);
8016+
check_spends!(spend_tx, closing_tx);
8017+
}
80008018
}

0 commit comments

Comments
 (0)