Skip to content

Commit 3a7b40e

Browse files
author
Antoine Riard
committed
Add test_static_output_closing_tx
1 parent 890d176 commit 3a7b40e

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/ln/channelmanager.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,7 +3672,7 @@ mod tests {
36723672
}
36733673
}
36743674

3675-
fn close_channel(outbound_node: &Node, inbound_node: &Node, channel_id: &[u8; 32], funding_tx: Transaction, close_inbound_first: bool) -> (msgs::ChannelUpdate, msgs::ChannelUpdate) {
3675+
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) {
36763676
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) };
36773677
let (node_b, broadcaster_b) = if close_inbound_first { (&outbound_node.node, &outbound_node.tx_broadcaster) } else { (&inbound_node.node, &inbound_node.tx_broadcaster) };
36783678
let (tx_a, tx_b);
@@ -3735,7 +3735,7 @@ mod tests {
37353735
assert_eq!(tx_a, tx_b);
37363736
check_spends!(tx_a, funding_tx);
37373737

3738-
(as_update, bs_update)
3738+
(as_update, bs_update, tx_a)
37393739
}
37403740

37413741
struct SendEvent {
@@ -7979,4 +7979,25 @@ mod tests {
79797979
check_spends!(spend_txn[0], local_txn[0].clone());
79807980
check_spends!(spend_txn[1], node_txn[0].clone());
79817981
}
7982+
7983+
#[test]
7984+
fn test_static_output_closing_tx() {
7985+
let nodes = create_network(2);
7986+
7987+
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
7988+
7989+
send_payment(&nodes[0], &vec!(&nodes[1])[..], 8000000);
7990+
let closing_tx = close_channel(&nodes[0], &nodes[1], &chan.2, chan.3, true).2;
7991+
7992+
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
7993+
nodes[0].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![closing_tx.clone()] }, 1);
7994+
let events = nodes[0].chan_monitor.simple_monitor.get_and_clear_pending_events();
7995+
let spend_tx = check_static_output!(events, nodes, 0, 0, 2, 0);
7996+
check_spends!(spend_tx, closing_tx.clone());
7997+
7998+
nodes[1].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![closing_tx.clone()] }, 1);
7999+
let events = nodes[1].chan_monitor.simple_monitor.get_and_clear_pending_events();
8000+
let spend_tx = check_static_output!(events, nodes, 0, 0, 2, 1);
8001+
check_spends!(spend_tx, closing_tx);
8002+
}
79828003
}

0 commit comments

Comments
 (0)