Skip to content

Commit

Permalink
f rename + better document test parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Jun 25, 2021
1 parent cc7d658 commit 642f5af
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]);
Expand All @@ -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());
Expand Down

0 comments on commit 642f5af

Please sign in to comment.