From 642f5af0cbc962632f0fbb754d9512b26f1782a8 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 25 Jun 2021 19:28:22 +0000 Subject: [PATCH] f rename + better document test parameter --- lightning/src/ln/functional_tests.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index e3a627b09a5..ad7004815f7 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -9262,7 +9262,7 @@ fn test_invalid_funding_tx() { assert_eq!(nodes[1].node.list_channels().len(), 0); } -fn do_test_tx_confirmed_skipping_blocks_immediate_broadcast(check_no_broadcast_too_early: bool) { +fn do_test_tx_confirmed_skipping_blocks_immediate_broadcast(test_height_before_timelock: bool) { // In the first version of the chain::Confirm interface, after a refactor was made to not // broadcast CSV-locked transactions until their CSV lock is up, we wouldn't reliably broadcast // transactions after a `transactions_confirmed` call. Specifically, if the chain, provided via @@ -9276,6 +9276,9 @@ fn do_test_tx_confirmed_skipping_blocks_immediate_broadcast(check_no_broadcast_t // height at which transactions were confirmed to `OnchainTx::update_claims_view`, it wasn't // aware that the anti-reorg-delay had, in fact, already expired, waiting to fail-backwards // until we learned about an additional block. + // + // As an additional check, if `test_height_before_timelock` is set, we instead test that we + // aren't broadcasting transactions too early (ie not broadcasting them at all). 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]); @@ -9295,14 +9298,12 @@ fn do_test_tx_confirmed_skipping_blocks_immediate_broadcast(check_no_broadcast_t assert_eq!(node_txn.len(), 1); let conf_height = nodes[1].best_block_info().1; - if !check_no_broadcast_too_early { + if !test_height_before_timelock { connect_blocks(&nodes[1], 24 * 6); - } else { - // As an additional check, test that we aren't broadcasting transactions too early, either } nodes[1].chain_monitor.chain_monitor.transactions_confirmed( &nodes[1].get_block_header(conf_height), &[(0, &node_txn[0])], conf_height); - if check_no_broadcast_too_early { + if test_height_before_timelock { // If we confirmed the close transaction, but timelocks have not yet expired, we should not // generate any events or broadcast any transactions assert!(nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().is_empty());