Skip to content

Commit 5e8b683

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 d45b38f commit 5e8b683

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lightning/src/ln/functional_tests.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2940,8 +2940,7 @@ fn test_htlc_on_chain_success() {
29402940
check_tx_local_broadcast!(nodes[0], true, commitment_tx[0], chan_1.3);
29412941
}
29422942

2943-
#[test]
2944-
fn test_htlc_on_chain_timeout() {
2943+
fn do_test_htlc_on_chain_timeout(connect_style: ConnectStyle) {
29452944
// Test that in case of a unilateral close onchain, we detect the state of output and
29462945
// timeout the HTLC backward accordingly. So here we test that ChannelManager is
29472946
// broadcasting the right event to other nodes in payment path.
@@ -2953,7 +2952,10 @@ fn test_htlc_on_chain_timeout() {
29532952
let chanmon_cfgs = create_chanmon_cfgs(3);
29542953
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
29552954
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]);
2956-
let nodes = create_network(3, &node_cfgs, &node_chanmgrs);
2955+
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
2956+
*nodes[0].connect_style.borrow_mut() = connect_style;
2957+
*nodes[1].connect_style.borrow_mut() = connect_style;
2958+
*nodes[2].connect_style.borrow_mut() = connect_style;
29572959

29582960
// Create some intial channels
29592961
let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
@@ -3067,6 +3069,13 @@ fn test_htlc_on_chain_timeout() {
30673069
assert_eq!(node_txn[2].clone().input[0].witness.last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT);
30683070
}
30693071

3072+
#[test]
3073+
fn test_htlc_on_chain_timeout() {
3074+
do_test_htlc_on_chain_timeout(ConnectStyle::BestBlockFirstSkippingBlocks);
3075+
do_test_htlc_on_chain_timeout(ConnectStyle::TransactionsFirstSkippingBlocks);
3076+
do_test_htlc_on_chain_timeout(ConnectStyle::FullBlockViaListen);
3077+
}
3078+
30703079
#[test]
30713080
fn test_simple_commitment_revoked_fail_backward() {
30723081
// Test that in case of a revoked commitment tx, we detect the resolution of output by justice tx

0 commit comments

Comments
 (0)