Skip to content

Commit 892690b

Browse files
author
Antoine Riard
committed
Add test_static_output_closing_tx
Test implementation of check_spend_closing_transaction
1 parent 357b1c0 commit 892690b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/ln/channelmanager.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3675,7 +3675,7 @@ mod tests {
36753675
}
36763676
}
36773677

3678-
fn close_channel(outbound_node: &Node, inbound_node: &Node, channel_id: &[u8; 32], funding_tx: Transaction, close_inbound_first: bool) -> (msgs::ChannelUpdate, msgs::ChannelUpdate) {
3678+
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) {
36793679
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) };
36803680
let (node_b, broadcaster_b) = if close_inbound_first { (&outbound_node.node, &outbound_node.tx_broadcaster) } else { (&inbound_node.node, &inbound_node.tx_broadcaster) };
36813681
let (tx_a, tx_b);
@@ -3738,7 +3738,7 @@ mod tests {
37383738
assert_eq!(tx_a, tx_b);
37393739
check_spends!(tx_a, funding_tx);
37403740

3741-
(as_update, bs_update)
3741+
(as_update, bs_update, tx_a)
37423742
}
37433743

37443744
struct SendEvent {
@@ -7899,4 +7899,20 @@ mod tests {
78997899
check_spends!(spend_txn[0], local_txn[0].clone());
79007900
check_spends!(spend_txn[1], node_txn[0].clone());
79017901
}
7902+
7903+
#[test]
7904+
fn test_static_output_closing_tx() {
7905+
let nodes = create_network(2);
7906+
7907+
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
7908+
7909+
send_payment(&nodes[0], &vec!(&nodes[1])[..], 8000000);
7910+
let closing_tx = close_channel(&nodes[0], &nodes[1], &chan.2, chan.3, true).2;
7911+
7912+
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
7913+
nodes[0].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![closing_tx.clone()] }, 1);
7914+
let events = nodes[0].chan_monitor.simple_monitor.get_and_clear_pending_events();
7915+
let spend_tx = check_static_output!(events, nodes, 0, 1, 2, 0);
7916+
check_spends!(spend_tx, closing_tx);
7917+
}
79027918
}

0 commit comments

Comments
 (0)