Skip to content

Commit 0ebdc9d

Browse files
author
Antoine Riard
committed
Add test_static_output_closing_tx
Test implementation of check_spend_closing_transaction
1 parent 512e0c5 commit 0ebdc9d

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 {
@@ -7888,4 +7888,20 @@ mod tests {
78887888
let spend_tx = check_dynamic_output!(events, 0, 1, node_txn[0].output[0].value);
78897889
check_spends!(spend_tx, node_txn[0].clone());
78907890
}
7891+
7892+
#[test]
7893+
fn test_static_output_closing_tx() {
7894+
let nodes = create_network(2);
7895+
7896+
let chan = create_announced_chan_between_nodes(&nodes, 0, 1);
7897+
7898+
send_payment(&nodes[0], &vec!(&nodes[1])[..], 8000000);
7899+
let closing_tx = close_channel(&nodes[0], &nodes[1], &chan.2, chan.3, true).2;
7900+
7901+
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
7902+
nodes[0].chain_monitor.block_connected_with_filtering(&Block { header, txdata: vec![closing_tx.clone()] }, 1);
7903+
let events = nodes[0].chan_monitor.simple_monitor.get_and_clear_pending_events();
7904+
let spend_tx = check_static_output!(events, nodes, 0, 1, 2, 0);
7905+
check_spends!(spend_tx, closing_tx);
7906+
}
78917907
}

0 commit comments

Comments
 (0)