Skip to content

Commit 702c374

Browse files
committed
Add some checks for the new field
1 parent c570853 commit 702c374

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,7 @@ pub struct ExpectedCloseEvent {
15341534
pub counterparty_node_id: Option<PublicKey>,
15351535
pub discard_funding: bool,
15361536
pub reason: Option<ClosureReason>,
1537+
pub channel_funding_txo: Option<OutPoint>,
15371538
}
15381539

15391540
impl ExpectedCloseEvent {
@@ -1544,6 +1545,7 @@ impl ExpectedCloseEvent {
15441545
counterparty_node_id: None,
15451546
discard_funding,
15461547
reason: Some(reason),
1548+
channel_funding_txo: None,
15471549
}
15481550
}
15491551
}
@@ -1562,12 +1564,14 @@ pub fn check_closed_events(node: &Node, expected_close_events: &[ExpectedCloseEv
15621564
reason,
15631565
counterparty_node_id,
15641566
channel_capacity_sats,
1567+
channel_funding_txo,
15651568
..
15661569
} if (
15671570
expected_event.channel_id.map(|expected| *channel_id == expected).unwrap_or(true) &&
15681571
expected_event.reason.as_ref().map(|expected| reason == expected).unwrap_or(true) &&
15691572
expected_event.counterparty_node_id.map(|expected| *counterparty_node_id == Some(expected)).unwrap_or(true) &&
1570-
expected_event.channel_capacity_sats.map(|expected| *channel_capacity_sats == Some(expected)).unwrap_or(true)
1573+
expected_event.channel_capacity_sats.map(|expected| *channel_capacity_sats == Some(expected)).unwrap_or(true) &&
1574+
expected_event.channel_funding_txo.map(|expected| *channel_funding_txo == Some(expected)).unwrap_or(true)
15711575
)
15721576
)));
15731577
}
@@ -1592,6 +1596,7 @@ pub fn check_closed_event(node: &Node, events_count: usize, expected_reason: Clo
15921596
counterparty_node_id: Some(*node_id),
15931597
discard_funding: is_check_discard_funding,
15941598
reason: Some(expected_reason.clone()),
1599+
channel_funding_txo: None,
15951600
}).collect::<Vec<_>>();
15961601
check_closed_events(node, expected_close_events.as_slice());
15971602
}

lightning/src/ln/functional_tests.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10596,17 +10596,21 @@ fn test_disconnect_in_funding_batch() {
1059610596
nodes[0].node.peer_disconnected(&nodes[2].node.get_our_node_id());
1059710597

1059810598
// The channels in the batch will close immediately.
10599-
let channel_id_1 = OutPoint { txid: tx.txid(), index: 0 }.to_channel_id();
10600-
let channel_id_2 = OutPoint { txid: tx.txid(), index: 1 }.to_channel_id();
10599+
let funding_txo_1 = OutPoint { txid: tx.txid(), index: 0 };
10600+
let funding_txo_2 = OutPoint { txid: tx.txid(), index: 1 };
10601+
let channel_id_1 = funding_txo_1.to_channel_id();
10602+
let channel_id_2 = funding_txo_2.to_channel_id();
1060110603
check_closed_events(&nodes[0], &[
1060210604
ExpectedCloseEvent {
1060310605
channel_id: Some(channel_id_1),
1060410606
discard_funding: true,
10607+
channel_funding_txo: Some(funding_txo_1),
1060510608
..Default::default()
1060610609
},
1060710610
ExpectedCloseEvent {
1060810611
channel_id: Some(channel_id_2),
1060910612
discard_funding: true,
10613+
channel_funding_txo: Some(funding_txo_2),
1061010614
..Default::default()
1061110615
},
1061210616
]);
@@ -10664,8 +10668,10 @@ fn test_batch_funding_close_after_funding_signed() {
1066410668
assert_eq!(nodes[0].tx_broadcaster.txn_broadcast().len(), 0);
1066510669

1066610670
// Force-close the channel for which we've completed the initial monitor.
10667-
let channel_id_1 = OutPoint { txid: tx.txid(), index: 0 }.to_channel_id();
10668-
let channel_id_2 = OutPoint { txid: tx.txid(), index: 1 }.to_channel_id();
10671+
let funding_txo_1 = OutPoint { txid: tx.txid(), index: 0 };
10672+
let funding_txo_2 = OutPoint { txid: tx.txid(), index: 1 };
10673+
let channel_id_1 = funding_txo_1.to_channel_id();
10674+
let channel_id_2 = funding_txo_2.to_channel_id();
1066910675
nodes[0].node.force_close_broadcasting_latest_txn(&channel_id_1, &nodes[1].node.get_our_node_id()).unwrap();
1067010676
check_added_monitors(&nodes[0], 2);
1067110677
{
@@ -10697,11 +10703,13 @@ fn test_batch_funding_close_after_funding_signed() {
1069710703
ExpectedCloseEvent {
1069810704
channel_id: Some(channel_id_1),
1069910705
discard_funding: true,
10706+
channel_funding_txo: Some(funding_txo_1),
1070010707
..Default::default()
1070110708
},
1070210709
ExpectedCloseEvent {
1070310710
channel_id: Some(channel_id_2),
1070410711
discard_funding: true,
10712+
channel_funding_txo: Some(funding_txo_2),
1070510713
..Default::default()
1070610714
},
1070710715
]);

0 commit comments

Comments
 (0)