Skip to content

Commit 6fc8391

Browse files
author
Antoine Riard
committed
Add test_static_output_closing_tx
1 parent 9c678f4 commit 6fc8391

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
@@ -3699,7 +3699,7 @@ mod tests {
36993699
}
37003700
}
37013701

3702-
fn close_channel(outbound_node: &Node, inbound_node: &Node, channel_id: &[u8; 32], funding_tx: Transaction, close_inbound_first: bool) -> (msgs::ChannelUpdate, msgs::ChannelUpdate) {
3702+
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) {
37033703
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) };
37043704
let (node_b, broadcaster_b) = if close_inbound_first { (&outbound_node.node, &outbound_node.tx_broadcaster) } else { (&inbound_node.node, &inbound_node.tx_broadcaster) };
37053705
let (tx_a, tx_b);
@@ -3762,7 +3762,7 @@ mod tests {
37623762
assert_eq!(tx_a, tx_b);
37633763
check_spends!(tx_a, funding_tx);
37643764

3765-
(as_update, bs_update)
3765+
(as_update, bs_update, tx_a)
37663766
}
37673767

37683768
struct SendEvent {
@@ -7952,4 +7952,22 @@ mod tests {
79527952
check_spends!(spend_txn[0], local_txn[0].clone());
79537953
check_spends!(spend_txn[1], node_txn[0].clone());
79547954
}
7955+
7956+
#[test]
7957+
fn test_static_output_closing_tx() {
7958+
let nodes = create_network(2);
7959+
7960+
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
7961+
7962+
send_payment(&nodes[0], &vec!(&nodes[1])[..], 8000000);
7963+
let closing_tx = close_channel(&nodes[0], &nodes[1], &chan.2, chan.3, true).2;
7964+
7965+
let events = nodes[0].node.get_and_clear_pending_events();
7966+
let spend_tx = check_static_output!(events, nodes, 0, 0, 2, 0);
7967+
check_spends!(spend_tx, closing_tx.clone());
7968+
7969+
let events = nodes[1].node.get_and_clear_pending_events();
7970+
let spend_tx = check_static_output!(events, nodes, 0, 0, 2, 1);
7971+
check_spends!(spend_tx, closing_tx);
7972+
}
79557973
}

0 commit comments

Comments
 (0)