From 5e8b6833339a67f2f9a498db74b43ef93629755c Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Sat, 10 Apr 2021 00:32:08 -0700 Subject: [PATCH] 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. --- lightning/src/ln/functional_tests.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index ca19ac8b4..9a0c06e77 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -2940,8 +2940,7 @@ fn test_htlc_on_chain_success() { check_tx_local_broadcast!(nodes[0], true, commitment_tx[0], chan_1.3); } -#[test] -fn test_htlc_on_chain_timeout() { +fn do_test_htlc_on_chain_timeout(connect_style: ConnectStyle) { // Test that in case of a unilateral close onchain, we detect the state of output and // timeout the HTLC backward accordingly. So here we test that ChannelManager is // broadcasting the right event to other nodes in payment path. @@ -2953,7 +2952,10 @@ fn test_htlc_on_chain_timeout() { let chanmon_cfgs = create_chanmon_cfgs(3); let node_cfgs = create_node_cfgs(3, &chanmon_cfgs); let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[None, None, None]); - let nodes = create_network(3, &node_cfgs, &node_chanmgrs); + let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs); + *nodes[0].connect_style.borrow_mut() = connect_style; + *nodes[1].connect_style.borrow_mut() = connect_style; + *nodes[2].connect_style.borrow_mut() = connect_style; // Create some intial channels 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() { assert_eq!(node_txn[2].clone().input[0].witness.last().unwrap().len(), OFFERED_HTLC_SCRIPT_WEIGHT); } +#[test] +fn test_htlc_on_chain_timeout() { + do_test_htlc_on_chain_timeout(ConnectStyle::BestBlockFirstSkippingBlocks); + do_test_htlc_on_chain_timeout(ConnectStyle::TransactionsFirstSkippingBlocks); + do_test_htlc_on_chain_timeout(ConnectStyle::FullBlockViaListen); +} + #[test] fn test_simple_commitment_revoked_fail_backward() { // Test that in case of a revoked commitment tx, we detect the resolution of output by justice tx -- 2.39.5