Skip to content

Commit 796e4ab

Browse files
committed
Parameterize test_htlc_on_chain_timeout
This test failed when ConnectionStyle was set to a SkippingBlocks variant because of a bug in ChannelMonitor::update_best_block. Parameterize the test with these styles to catch any regressions.
1 parent a316b70 commit 796e4ab

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub fn confirm_transaction_at<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &T
7777
}
7878

7979
/// The possible ways we may notify a ChannelManager of a new block
80+
#[derive(Clone, Copy)]
8081
pub enum ConnectStyle {
8182
/// Calls update_best_block first, detecting transactions in the block only after receiving the
8283
/// header and height information.

lightning/src/ln/functional_tests.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,8 +2947,7 @@ fn test_htlc_on_chain_success() {
29472947
check_tx_local_broadcast!(nodes[0], true, commitment_tx[0], chan_1.3);
29482948
}
29492949

2950-
#[test]
2951-
fn test_htlc_on_chain_timeout() {
2950+
fn do_test_htlc_on_chain_timeout(connect_style: ConnectStyle) {
29522951
// Test that in case of a unilateral close onchain, we detect the state of output and
29532952
// timeout the HTLC backward accordingly. So here we test that ChannelManager is
29542953
// broadcasting the right event to other nodes in payment path.
@@ -2961,6 +2960,9 @@ fn test_htlc_on_chain_timeout() {
29612960
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
29622961
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
29632962
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
2963+
*nodes[0].connect_style.borrow_mut() = connect_style;
2964+
*nodes[1].connect_style.borrow_mut() = connect_style;
2965+
*nodes[2].connect_style.borrow_mut() = connect_style;
29642966

29652967
// Create some intial channels
29662968
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
@@ -3074,6 +3076,13 @@ fn test_htlc_on_chain_timeout() {
30743076
assert_eq!(node_txn[2].clone().input[0].witness.last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT);
30753077
}
30763078

3079+
#[test]
3080+
fn test_htlc_on_chain_timeout() {
3081+
do_test_htlc_on_chain_timeout(ConnectStyle::BestBlockFirstSkippingBlocks);
3082+
do_test_htlc_on_chain_timeout(ConnectStyle::TransactionsFirstSkippingBlocks);
3083+
do_test_htlc_on_chain_timeout(ConnectStyle::FullBlockViaListen);
3084+
}
3085+
30773086
#[test]
30783087
fn test_simple_commitment_revoked_fail_backward() {
30793088
// Test that in case of a revoked commitment tx, we detect the resolution of output by justice tx

0 commit comments

Comments
 (0)