From: Jeffrey Czyz Date: Tue, 14 Jul 2020 17:29:11 +0000 (-0700) Subject: Add test utilities for {dis}connecting a block X-Git-Tag: v0.0.12~21^2~18 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=1ab0a1acc1e3880b9cb9aece4cd4274bef9c7973;p=rust-lightning Add test utilities for {dis}connecting a block Replace direct uses of BlockNotifier in functional tests with utility functions. This is in preparation for signaling watch events back via a refactoring of ManyChannelMonitor and ChainWatchInterface. Those events will be processed by connect_block. --- diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 31af99039..f8f324c9b 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -46,7 +46,6 @@ use std::collections::HashMap; pub const CHAN_CONFIRM_DEPTH: u32 = 100; pub fn confirm_transaction<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &Transaction) { - let notifier = &node.block_notifier; let dummy_tx = Transaction { version: 0, lock_time: 0, input: Vec::new(), output: Vec::new() }; let dummy_tx_count = tx.version as usize; let mut block = Block { @@ -54,33 +53,40 @@ pub fn confirm_transaction<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &Tran txdata: vec![dummy_tx; dummy_tx_count], }; block.txdata.push(tx.clone()); - notifier.block_connected(&block, 1); + connect_block(node, &block, 1); for i in 2..CHAN_CONFIRM_DEPTH { block = Block { header: BlockHeader { version: 0x20000000, prev_blockhash: block.header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - notifier.block_connected(&block, i); + connect_block(node, &block, i); } } pub fn connect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, depth: u32, height: u32, parent: bool, prev_blockhash: BlockHash) -> BlockHash { - let notifier = &node.block_notifier; let mut block = Block { header: BlockHeader { version: 0x2000000, prev_blockhash: if parent { prev_blockhash } else { Default::default() }, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - notifier.block_connected(&block, height + 1); + connect_block(node, &block, height + 1); for i in 2..depth + 1 { block = Block { header: BlockHeader { version: 0x20000000, prev_blockhash: block.header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - notifier.block_connected(&block, height + i); + connect_block(node, &block, height + i); } block.header.block_hash() } +pub fn connect_block<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, block: &Block, height: u32) { + node.block_notifier.block_connected(block, height) +} + +pub fn disconnect_block<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, header: &BlockHeader, height: u32) { + node.block_notifier.block_disconnected(header, height) +} + pub struct TestChanMonCfg { pub tx_broadcaster: test_utils::TestBroadcaster, pub fee_estimator: test_utils::TestFeeEstimator, diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 39f6a600e..4bb48fc9e 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -424,10 +424,10 @@ fn test_1_conf_open() { header: BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![tx], }; - nodes[1].block_notifier.block_connected(&block, 1); + connect_block(&nodes[1], &block, 1); nodes[0].node.handle_funding_locked(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingLocked, nodes[0].node.get_our_node_id())); - nodes[0].block_notifier.block_connected(&block, 1); + connect_block(&nodes[0], &block, 1); let (funding_locked, _) = create_chan_between_nodes_with_value_confirm_second(&nodes[1], &nodes[0]); let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &funding_locked); @@ -454,8 +454,8 @@ fn do_test_sanity_on_in_flight_opens(steps: u8) { header: BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - nodes[0].block_notifier.block_connected(&block, 1); - nodes[1].block_notifier.block_connected(&block, 1); + connect_block(&nodes[0], &block, 1); + connect_block(&nodes[1], &block, 1); } if steps & 0x0f == 0 { return; } @@ -836,8 +836,8 @@ fn pre_funding_lock_shutdown_test() { let nodes = create_network(2, &node_cfgs, &node_chanmgrs); let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 8000000, 0, InitFeatures::known(), InitFeatures::known()); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![tx.clone()]}, 1); - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![tx.clone()]}, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![tx.clone()]}, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![tx.clone()]}, 1); nodes[0].node.close_channel(&OutPoint { txid: tx.txid(), index: 0 }.to_channel_id()).unwrap(); let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id()); @@ -1504,7 +1504,7 @@ fn test_duplicate_htlc_different_direction_onchain() { assert_eq!(has_both_htlcs, 2); let header = BlockHeader { version: 0x2000_0000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![remote_txn[0].clone()] }, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![remote_txn[0].clone()] }, 1); check_added_monitors!(nodes[0], 1); // Check we only broadcast 1 timeout tx @@ -2346,7 +2346,7 @@ fn channel_monitor_network_test() { { let mut node_txn = test_txn_broadcast(&nodes[1], &chan_1, None, HTLCType::NONE); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![node_txn.drain(..).next().unwrap()] }, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![node_txn.drain(..).next().unwrap()] }, 1); check_added_monitors!(nodes[0], 1); test_txn_broadcast(&nodes[0], &chan_1, None, HTLCType::NONE); } @@ -2363,7 +2363,7 @@ fn channel_monitor_network_test() { { let mut node_txn = test_txn_broadcast(&nodes[1], &chan_2, None, HTLCType::TIMEOUT); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[2].block_notifier.block_connected(&Block { header, txdata: vec![node_txn.drain(..).next().unwrap()] }, 1); + connect_block(&nodes[2], &Block { header, txdata: vec![node_txn.drain(..).next().unwrap()] }, 1); check_added_monitors!(nodes[2], 1); test_txn_broadcast(&nodes[2], &chan_2, None, HTLCType::NONE); } @@ -2404,7 +2404,7 @@ fn channel_monitor_network_test() { claim_funds!(nodes[3], nodes[2], payment_preimage_1, 3_000_000); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[3].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[0].clone()] }, 1); + connect_block(&nodes[3], &Block { header, txdata: vec![node_txn[0].clone()] }, 1); check_added_monitors!(nodes[3], 1); check_preimage_claim(&nodes[3], &node_txn); @@ -2415,7 +2415,7 @@ fn channel_monitor_network_test() { { // Cheat and reset nodes[4]'s height to 1 let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[4].block_notifier.block_connected(&Block { header, txdata: vec![] }, 1); + connect_block(&nodes[4], &Block { header, txdata: vec![] }, 1); } assert_eq!(nodes[3].node.latest_block_height.load(Ordering::Acquire), 1); @@ -2430,13 +2430,13 @@ fn channel_monitor_network_test() { header: BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - nodes[3].block_notifier.block_connected(&block, 2); + connect_block(&nodes[3], &block, 2); for i in 3..TEST_FINAL_CLTV + 2 + LATENCY_GRACE_PERIOD_BLOCKS + 1 { block = Block { header: BlockHeader { version: 0x20000000, prev_blockhash: block.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - nodes[3].block_notifier.block_connected(&block, i); + connect_block(&nodes[3], &block, i); } let events = nodes[3].node.get_and_clear_pending_msg_events(); assert_eq!(events.len(), 1); @@ -2468,13 +2468,13 @@ fn channel_monitor_network_test() { txdata: vec![], }; - nodes[4].block_notifier.block_connected(&block, 2); + connect_block(&nodes[4], &block, 2); for i in 3..TEST_FINAL_CLTV + 2 - CLTV_CLAIM_BUFFER + 1 { block = Block { header: BlockHeader { version: 0x20000000, prev_blockhash: block.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - nodes[4].block_notifier.block_connected(&block, i); + connect_block(&nodes[4], &block, i); } let events = nodes[4].node.get_and_clear_pending_msg_events(); assert_eq!(events.len(), 1); @@ -2491,7 +2491,7 @@ fn channel_monitor_network_test() { header: BlockHeader { version: 0x20000000, prev_blockhash: block.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![node_txn[0].clone()], }; - nodes[4].block_notifier.block_connected(&block, TEST_FINAL_CLTV - 5); + connect_block(&nodes[4], &block, TEST_FINAL_CLTV - 5); check_preimage_claim(&nodes[4], &node_txn); (close_chan_update_1, close_chan_update_2) @@ -2537,7 +2537,7 @@ fn test_justice_tx() { { let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); { let mut node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap(); assert_eq!(node_txn.len(), 2); // ChannelMonitor: penalty tx, ChannelManager: local commitment tx @@ -2550,13 +2550,13 @@ fn test_justice_tx() { check_added_monitors!(nodes[1], 1); test_txn_broadcast(&nodes[1], &chan_5, None, HTLCType::NONE); - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); // Verify broadcast of revoked HTLC-timeout let node_txn = test_txn_broadcast(&nodes[0], &chan_5, Some(revoked_local_txn[0].clone()), HTLCType::TIMEOUT); header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; check_added_monitors!(nodes[0], 1); // Broadcast revoked HTLC-timeout on node 1 - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[1].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![node_txn[1].clone()] }, 1); test_revoked_htlc_claim_txn_broadcast(&nodes[1], node_txn[1].clone(), revoked_local_txn[0].clone()); } get_announce_close_broadcast_events(&nodes, 0, 1); @@ -2584,7 +2584,7 @@ fn test_justice_tx() { claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage_4, 3_000_000); { let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); { let mut node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap(); assert_eq!(node_txn.len(), 2); //ChannelMonitor: penalty tx, ChannelManager: local commitment tx @@ -2596,11 +2596,11 @@ fn test_justice_tx() { check_added_monitors!(nodes[0], 1); test_txn_broadcast(&nodes[0], &chan_6, None, HTLCType::NONE); - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); let node_txn = test_txn_broadcast(&nodes[1], &chan_6, Some(revoked_local_txn[0].clone()), HTLCType::SUCCESS); header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; check_added_monitors!(nodes[1], 1); - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[1].clone()] }, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![node_txn[1].clone()] }, 1); test_revoked_htlc_claim_txn_broadcast(&nodes[0], node_txn[1].clone(), revoked_local_txn[0].clone()); } get_announce_close_broadcast_events(&nodes, 0, 1); @@ -2627,7 +2627,7 @@ fn revoked_output_claim() { // Inform nodes[1] that nodes[0] broadcast a stale tx let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); check_added_monitors!(nodes[1], 1); let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap(); assert_eq!(node_txn.len(), 2); // ChannelMonitor: justice tx against revoked to_local output, ChannelManager: local commitment tx @@ -2636,7 +2636,7 @@ fn revoked_output_claim() { check_spends!(node_txn[1], chan_1.3); // Inform nodes[0] that a watchtower cheated on its behalf, so it will force-close the chan - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); get_announce_close_broadcast_events(&nodes, 0, 1); check_added_monitors!(nodes[0], 1) } @@ -2673,9 +2673,9 @@ fn claim_htlc_outputs_shared_tx() { { let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); check_added_monitors!(nodes[0], 1); - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); check_added_monitors!(nodes[1], 1); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); expect_payment_failed!(nodes[1], payment_hash_2, true); @@ -2736,9 +2736,9 @@ fn claim_htlc_outputs_single_tx() { { let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 200); + connect_block(&nodes[0], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 200); check_added_monitors!(nodes[0], 1); - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 200); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 200); check_added_monitors!(nodes[1], 1); expect_pending_htlcs_forwardable_ignore!(nodes[0]); @@ -2830,7 +2830,7 @@ fn test_htlc_on_chain_success() { assert!(updates.update_fail_malformed_htlcs.is_empty()); assert_eq!(updates.update_fulfill_htlcs.len(), 1); - nodes[2].block_notifier.block_connected(&Block { header, txdata: vec![commitment_tx[0].clone()]}, 1); + connect_block(&nodes[2], &Block { header, txdata: vec![commitment_tx[0].clone()]}, 1); check_closed_broadcast!(nodes[2], false); check_added_monitors!(nodes[2], 1); let node_txn = nodes[2].tx_broadcaster.txn_broadcasted.lock().unwrap().clone(); // ChannelManager : 3 (commitment tx, 2*htlc-success tx), ChannelMonitor : 2 (2 * HTLC-Success tx) @@ -2848,7 +2848,7 @@ fn test_htlc_on_chain_success() { assert_eq!(node_txn[1].lock_time, 0); // Verify that B's ChannelManager is able to extract preimage from HTLC Success tx and pass it backward - nodes[1].block_notifier.block_connected(&Block { header, txdata: node_txn}, 1); + connect_block(&nodes[1], &Block { header, txdata: node_txn}, 1); { let mut added_monitors = nodes[1].chan_monitor.added_monitors.lock().unwrap(); assert_eq!(added_monitors.len(), 1); @@ -2921,7 +2921,7 @@ fn test_htlc_on_chain_success() { // Broadcast preimage tx by B on offered output from A commitment tx on A's chain let commitment_tx = get_local_commitment_txn!(nodes[0], chan_1.2); check_spends!(commitment_tx[0], chan_1.3); - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![commitment_tx[0].clone()]}, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![commitment_tx[0].clone()]}, 1); check_closed_broadcast!(nodes[1], false); check_added_monitors!(nodes[1], 1); let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().clone(); // ChannelManager : 3 (commitment tx + HTLC-Sucess * 2), ChannelMonitor : 1 (HTLC-Success) @@ -2940,7 +2940,7 @@ fn test_htlc_on_chain_success() { // we already checked the same situation with A. // Verify that A's ChannelManager is able to extract preimage from preimage tx and generate PaymentSent - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![commitment_tx[0].clone(), node_txn[0].clone()] }, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![commitment_tx[0].clone(), node_txn[0].clone()] }, 1); check_closed_broadcast!(nodes[0], false); check_added_monitors!(nodes[0], 1); let events = nodes[0].node.get_and_clear_pending_events(); @@ -3008,7 +3008,7 @@ fn test_htlc_on_chain_timeout() { }, _ => panic!("Unexpected event"), }; - nodes[2].block_notifier.block_connected(&Block { header, txdata: vec![commitment_tx[0].clone()]}, 1); + connect_block(&nodes[2], &Block { header, txdata: vec![commitment_tx[0].clone()]}, 1); check_closed_broadcast!(nodes[2], false); check_added_monitors!(nodes[2], 1); let node_txn = nodes[2].tx_broadcaster.txn_broadcasted.lock().unwrap().clone(); // ChannelManager : 1 (commitment tx) @@ -3018,7 +3018,7 @@ fn test_htlc_on_chain_timeout() { // Broadcast timeout transaction by B on received output from C's commitment tx on B's chain // Verify that B's ChannelManager is able to detect that HTLC is timeout by its own tx and react backward in consequence - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![commitment_tx[0].clone()]}, 200); + connect_block(&nodes[1], &Block { header, txdata: vec![commitment_tx[0].clone()]}, 200); let timeout_tx; { let mut node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap(); @@ -3038,7 +3038,7 @@ fn test_htlc_on_chain_timeout() { node_txn.clear(); } - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![timeout_tx]}, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![timeout_tx]}, 1); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); check_added_monitors!(nodes[1], 1); check_closed_broadcast!(nodes[1], false); @@ -3064,7 +3064,7 @@ fn test_htlc_on_chain_timeout() { let commitment_tx = get_local_commitment_txn!(nodes[1], chan_1.2); check_spends!(commitment_tx[0], chan_1.3); - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![commitment_tx[0].clone()]}, 200); + connect_block(&nodes[0], &Block { header, txdata: vec![commitment_tx[0].clone()]}, 200); check_closed_broadcast!(nodes[0], false); check_added_monitors!(nodes[0], 1); let node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().clone(); // ChannelManager : 2 (commitment tx, HTLC-Timeout tx), ChannelMonitor : 1 timeout tx @@ -3100,7 +3100,7 @@ fn test_simple_commitment_revoked_fail_backward() { let (_, payment_hash) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 3000000); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42}; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); check_added_monitors!(nodes[1], 1); check_closed_broadcast!(nodes[1], false); @@ -3253,7 +3253,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive(deliver_bs_raa: bool, use assert!(nodes[1].node.get_and_clear_pending_events().is_empty()); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42}; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); check_added_monitors!(nodes[1], 1); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); @@ -3448,13 +3448,13 @@ fn test_htlc_ignore_latest_remote_commitment() { assert_eq!(node_txn.len(), 2); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[0].clone(), node_txn[1].clone()]}, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![node_txn[0].clone(), node_txn[1].clone()]}, 1); check_closed_broadcast!(nodes[1], false); check_added_monitors!(nodes[1], 1); - // Duplicate the block_connected call since this may happen due to other listeners + // Duplicate the connect_block call since this may happen due to other listeners // registering new transactions - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[0].clone(), node_txn[1].clone()]}, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![node_txn[0].clone(), node_txn[1].clone()]}, 1); } #[test] @@ -3517,7 +3517,7 @@ fn test_force_close_fail_back() { header: BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![tx.clone()], }; - nodes[1].block_notifier.block_connected(&block, 1); + connect_block(&nodes[1], &block, 1); // Note no UpdateHTLCs event here from nodes[1] to nodes[0]! check_closed_broadcast!(nodes[1], false); @@ -3529,7 +3529,7 @@ fn test_force_close_fail_back() { monitors.get_mut(&OutPoint{ txid: Txid::from_slice(&payment_event.commitment_msg.channel_id[..]).unwrap(), index: 0 }).unwrap() .provide_payment_preimage(&our_payment_hash, &our_payment_preimage); } - nodes[2].block_notifier.block_connected(&block, 1); + connect_block(&nodes[2], &block, 1); let node_txn = nodes[2].tx_broadcaster.txn_broadcasted.lock().unwrap(); assert_eq!(node_txn.len(), 1); assert_eq!(node_txn[0].input.len(), 1); @@ -4111,12 +4111,12 @@ fn do_test_htlc_timeout(send_partial_mpp: bool) { header: BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - nodes[0].block_notifier.block_connected(&block, 101); - nodes[1].block_notifier.block_connected(&block, 101); + connect_block(&nodes[0], &block, 101); + connect_block(&nodes[1], &block, 101); for i in 102..TEST_FINAL_CLTV + 100 + 1 - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS { block.header.prev_blockhash = block.block_hash(); - nodes[0].block_notifier.block_connected(&block, i); - nodes[1].block_notifier.block_connected(&block, i); + connect_block(&nodes[0], &block, i); + connect_block(&nodes[1], &block, i); } expect_pending_htlcs_forwardable!(nodes[1]); @@ -4185,17 +4185,17 @@ fn do_test_holding_cell_htlc_add_timeouts(forwarded_htlc: bool) { header: BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - nodes[1].block_notifier.block_connected(&block, 101); + connect_block(&nodes[1], &block, 101); for i in 102..TEST_FINAL_CLTV + 100 - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS { block.header.prev_blockhash = block.block_hash(); - nodes[1].block_notifier.block_connected(&block, i); + connect_block(&nodes[1], &block, i); } assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty()); assert!(nodes[1].node.get_and_clear_pending_events().is_empty()); block.header.prev_blockhash = block.block_hash(); - nodes[1].block_notifier.block_connected(&block, TEST_FINAL_CLTV + 100 - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS); + connect_block(&nodes[1], &block, TEST_FINAL_CLTV + 100 - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS); if forwarded_htlc { expect_pending_htlcs_forwardable!(nodes[1]); @@ -4826,7 +4826,7 @@ fn test_claim_sizeable_push_msat() { assert_eq!(node_txn[0].output.len(), 2); // We can't force trimming of to_remote output as channel_reserve_satoshis block us to do so at channel opening let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[0].clone()] }, 0); + connect_block(&nodes[1], &Block { header, txdata: vec![node_txn[0].clone()] }, 0); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000); @@ -4854,7 +4854,7 @@ fn test_claim_on_remote_sizeable_push_msat() { assert_eq!(node_txn[0].output.len(), 2); // We can't force trimming of to_remote output as channel_reserve_satoshis block us to do so at channel opening let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[0].clone()] }, 0); + connect_block(&nodes[1], &Block { header, txdata: vec![node_txn[0].clone()] }, 0); check_closed_broadcast!(nodes[1], false); check_added_monitors!(nodes[1], 1); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); @@ -4883,13 +4883,13 @@ fn test_claim_on_remote_revoked_sizeable_push_msat() { claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage, 3_000_000); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 0); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 0); check_closed_broadcast!(nodes[1], false); check_added_monitors!(nodes[1], 1); let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap(); let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000); @@ -4919,7 +4919,7 @@ fn test_static_spendable_outputs_preimage_tx() { let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; assert!(nodes[1].node.claim_funds(payment_preimage, &None, 3_000_000)); check_added_monitors!(nodes[1], 1); - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![commitment_tx[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![commitment_tx[0].clone()] }, 1); check_added_monitors!(nodes[1], 1); let events = nodes[1].node.get_and_clear_pending_msg_events(); match events[0] { @@ -4940,7 +4940,7 @@ fn test_static_spendable_outputs_preimage_tx() { check_spends!(node_txn[2], node_txn[1]); let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000); @@ -4969,7 +4969,7 @@ fn test_static_spendable_outputs_timeout_tx() { // Settle A's commitment tx on B' chain let header = BlockHeader { version: 0x2000_0000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42}; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![commitment_tx[0].clone()] }, 0); + connect_block(&nodes[1], &Block { header, txdata: vec![commitment_tx[0].clone()] }, 0); check_added_monitors!(nodes[1], 1); let events = nodes[1].node.get_and_clear_pending_msg_events(); match events[0] { @@ -4986,7 +4986,7 @@ fn test_static_spendable_outputs_timeout_tx() { check_spends!(node_txn[2], node_txn[1]); let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); expect_payment_failed!(nodes[1], our_payment_hash, true); @@ -5013,7 +5013,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_commitment_tx() { claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage, 3_000_000); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 0); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 0); check_closed_broadcast!(nodes[1], false); check_added_monitors!(nodes[1], 1); @@ -5023,7 +5023,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_commitment_tx() { check_spends!(node_txn[0], revoked_local_txn[0]); let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header: header_1, txdata: vec![node_txn[0].clone()] }, 1); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); let spend_txn = check_spendable_outputs!(nodes[1], 1, node_cfgs[1].keys_manager, 100000); @@ -5050,7 +5050,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() { let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; // A will generate HTLC-Timeout from revoked commitment tx - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); check_closed_broadcast!(nodes[0], false); check_added_monitors!(nodes[0], 1); @@ -5062,7 +5062,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() { check_spends!(revoked_htlc_txn[1], chan_1.3); // B will generate justice tx from A's revoked commitment/HTLC tx - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone(), revoked_htlc_txn[0].clone()] }, 0); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone(), revoked_htlc_txn[0].clone()] }, 0); check_closed_broadcast!(nodes[1], false); check_added_monitors!(nodes[1], 1); @@ -5087,7 +5087,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() { check_spends!(node_txn[2], chan_1.3); let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[1].clone()] }, 1); + connect_block(&nodes[1], &Block { header: header_1, txdata: vec![node_txn[1].clone()] }, 1); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); // Check B's ChannelMonitor was able to generate the right spendable output descriptor @@ -5119,7 +5119,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_success_tx() { let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; // B will generate HTLC-Success from revoked commitment tx - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); check_closed_broadcast!(nodes[1], false); check_added_monitors!(nodes[1], 1); let revoked_htlc_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap(); @@ -5134,7 +5134,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_success_tx() { assert_eq!(revoked_local_txn[0].output[unspent_local_txn_output].script_pubkey.len(), 2 + 20); // P2WPKH // A will generate justice tx from B's revoked commitment/HTLC tx - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone(), revoked_htlc_txn[0].clone()] }, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![revoked_local_txn[0].clone(), revoked_htlc_txn[0].clone()] }, 1); check_closed_broadcast!(nodes[0], false); check_added_monitors!(nodes[0], 1); @@ -5159,7 +5159,7 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_success_tx() { check_spends!(node_txn[2], chan_1.3); let header_1 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header: header_1, txdata: vec![node_txn[1].clone()] }, 1); + connect_block(&nodes[0], &Block { header: header_1, txdata: vec![node_txn[1].clone()] }, 1); connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); // Note that nodes[0]'s tx_broadcaster is still locked, so if we get here the channelmonitor @@ -5210,7 +5210,7 @@ fn test_onchain_to_onchain_claim() { assert_eq!(updates.update_fulfill_htlcs.len(), 1); assert!(updates.update_fail_malformed_htlcs.is_empty()); - nodes[2].block_notifier.block_connected(&Block { header, txdata: vec![commitment_tx[0].clone()]}, 1); + connect_block(&nodes[2], &Block { header, txdata: vec![commitment_tx[0].clone()]}, 1); check_closed_broadcast!(nodes[2], false); check_added_monitors!(nodes[2], 1); @@ -5226,7 +5226,7 @@ fn test_onchain_to_onchain_claim() { assert_eq!(c_txn[0].lock_time, 0); // Success tx // So we broadcast C's commitment tx and HTLC-Success on B's chain, we should successfully be able to extract preimage and update downstream monitor - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![c_txn[1].clone(), c_txn[2].clone()]}, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![c_txn[1].clone(), c_txn[2].clone()]}, 1); { let mut b_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap(); // ChannelMonitor: claim tx, ChannelManager: local commitment tx + HTLC-timeout tx @@ -5261,7 +5261,7 @@ fn test_onchain_to_onchain_claim() { }; // Broadcast A's commitment tx on B's chain to see if we are able to claim inbound HTLC with our HTLC-Success tx let commitment_tx = get_local_commitment_txn!(nodes[0], chan_1.2); - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![commitment_tx[0].clone()]}, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![commitment_tx[0].clone()]}, 1); let b_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap(); // ChannelMonitor: HTLC-Success tx, ChannelManager: local commitment tx + HTLC-Success tx assert_eq!(b_txn.len(), 3); @@ -5297,7 +5297,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() { check_spends!(commitment_txn[0], chan_2.3); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![commitment_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![commitment_txn[0].clone()] }, 1); check_closed_broadcast!(nodes[1], false); check_added_monitors!(nodes[1], 1); @@ -5320,7 +5320,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() { } nodes[2].node.claim_funds(our_payment_preimage, &None, 900_000); - nodes[2].block_notifier.block_connected(&Block { header, txdata: vec![commitment_txn[0].clone()] }, 1); + connect_block(&nodes[2], &Block { header, txdata: vec![commitment_txn[0].clone()] }, 1); check_added_monitors!(nodes[2], 3); let events = nodes[2].node.get_and_clear_pending_msg_events(); match events[0] { @@ -5346,7 +5346,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() { check_spends!(htlc_success_txn[0], commitment_txn[0]); check_spends!(htlc_success_txn[1], commitment_txn[0]); - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![htlc_timeout_tx] }, 200); + connect_block(&nodes[1], &Block { header, txdata: vec![htlc_timeout_tx] }, 200); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 200, true, header.block_hash()); expect_pending_htlcs_forwardable!(nodes[1]); let htlc_updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); @@ -5372,7 +5372,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() { expect_payment_failed!(nodes[0], duplicate_payment_hash, false); // Solve 2nd HTLC by broadcasting on B's chain HTLC-Success Tx from C - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![htlc_success_txn[0].clone()] }, 200); + connect_block(&nodes[1], &Block { header, txdata: vec![htlc_success_txn[0].clone()] }, 200); let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); assert!(updates.update_add_htlcs.is_empty()); assert!(updates.update_fail_htlcs.is_empty()); @@ -5412,7 +5412,7 @@ fn test_dynamic_spendable_outputs_local_htlc_success_tx() { nodes[1].node.claim_funds(payment_preimage, &None, 9_000_000); check_added_monitors!(nodes[1], 1); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![local_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![local_txn[0].clone()] }, 1); check_added_monitors!(nodes[1], 1); let events = nodes[1].node.get_and_clear_pending_msg_events(); match events[0] { @@ -5432,7 +5432,7 @@ fn test_dynamic_spendable_outputs_local_htlc_success_tx() { }; let header_201 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header: header_201, txdata: node_txn.clone() }, 201); + connect_block(&nodes[1], &Block { header: header_201, txdata: node_txn.clone() }, 201); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 201, true, header_201.block_hash()); // Verify that B is able to spend its own HTLC-Success tx thanks to spendable output event given back by its ChannelMonitor @@ -5573,9 +5573,9 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; if announce_latest { - nodes[2].block_notifier.block_connected(&Block { header, txdata: vec![ds_last_commitment_tx[0].clone()]}, 1); + connect_block(&nodes[2], &Block { header, txdata: vec![ds_last_commitment_tx[0].clone()]}, 1); } else { - nodes[2].block_notifier.block_connected(&Block { header, txdata: vec![ds_prev_commitment_tx[0].clone()]}, 1); + connect_block(&nodes[2], &Block { header, txdata: vec![ds_prev_commitment_tx[0].clone()]}, 1); } connect_blocks(&nodes[2], ANTI_REORG_DELAY - 1, 1, true, header.block_hash()); check_closed_broadcast!(nodes[2], false); @@ -5715,7 +5715,7 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() { // Timeout HTLC on A's chain and so it can generate a HTLC-Timeout tx let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![local_txn[0].clone()] }, 200); + connect_block(&nodes[0], &Block { header, txdata: vec![local_txn[0].clone()] }, 200); check_closed_broadcast!(nodes[0], false); check_added_monitors!(nodes[0], 1); @@ -5728,7 +5728,7 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() { }; let header_201 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header: header_201, txdata: vec![htlc_timeout.clone()] }, 201); + connect_block(&nodes[0], &Block { header: header_201, txdata: vec![htlc_timeout.clone()] }, 201); connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1, 201, true, header_201.block_hash()); expect_payment_failed!(nodes[0], our_payment_hash, true); @@ -5785,7 +5785,7 @@ fn test_key_derivation_params() { // Timeout HTLC on A's chain and so it can generate a HTLC-Timeout tx let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![local_txn_1[0].clone()] }, 200); + connect_block(&nodes[0], &Block { header, txdata: vec![local_txn_1[0].clone()] }, 200); check_closed_broadcast!(nodes[0], false); check_added_monitors!(nodes[0], 1); @@ -5798,7 +5798,7 @@ fn test_key_derivation_params() { }; let header_201 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header: header_201, txdata: vec![htlc_timeout.clone()] }, 201); + connect_block(&nodes[0], &Block { header: header_201, txdata: vec![htlc_timeout.clone()] }, 201); connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1, 201, true, header_201.block_hash()); expect_payment_failed!(nodes[0], our_payment_hash, true); @@ -5824,14 +5824,14 @@ fn test_static_output_closing_tx() { let closing_tx = close_channel(&nodes[0], &nodes[1], &chan.2, chan.3, true).2; let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![closing_tx.clone()] }, 0); + connect_block(&nodes[0], &Block { header, txdata: vec![closing_tx.clone()] }, 0); connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1, 0, true, header.block_hash()); let spend_txn = check_spendable_outputs!(nodes[0], 2, node_cfgs[0].keys_manager, 100000); assert_eq!(spend_txn.len(), 1); check_spends!(spend_txn[0], closing_tx); - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![closing_tx.clone()] }, 0); + connect_block(&nodes[1], &Block { header, txdata: vec![closing_tx.clone()] }, 0); connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1, 0, true, header.block_hash()); let spend_txn = check_spendable_outputs!(nodes[1], 2, node_cfgs[1].keys_manager, 100000); @@ -5875,7 +5875,7 @@ fn do_htlc_claim_local_commitment_only(use_dust: bool) { txdata: vec![], }; for i in 1..TEST_FINAL_CLTV - CLTV_CLAIM_BUFFER + CHAN_CONFIRM_DEPTH + 1 { - nodes[1].block_notifier.block_connected(&block, i); + connect_block(&nodes[1], &block, i); block.header.prev_blockhash = block.block_hash(); } test_txn_broadcast(&nodes[1], &chan, None, if use_dust { HTLCType::NONE } else { HTLCType::SUCCESS }); @@ -5906,7 +5906,7 @@ fn do_htlc_claim_current_remote_commitment_only(use_dust: bool) { let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; for i in 1..TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS + CHAN_CONFIRM_DEPTH + 1 { - nodes[0].block_notifier.block_connected(&Block { header, txdata: Vec::new()}, i); + connect_block(&nodes[0], &Block { header, txdata: Vec::new()}, i); header.prev_blockhash = header.block_hash(); } test_txn_broadcast(&nodes[0], &chan, None, HTLCType::NONE); @@ -5952,7 +5952,7 @@ fn do_htlc_claim_previous_remote_commitment_only(use_dust: bool, check_revoke_no txdata: vec![], }; for i in 1..TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS + CHAN_CONFIRM_DEPTH + 1 { - nodes[0].block_notifier.block_connected(&block, i); + connect_block(&nodes[0], &block, i); block.header.prev_blockhash = block.block_hash(); } if !check_revoke_no_close { @@ -7132,9 +7132,9 @@ fn do_test_failure_delay_dust_htlc_local_commitment(announce_latest: bool) { let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; if announce_latest { - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![as_last_commitment_tx[0].clone()]}, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![as_last_commitment_tx[0].clone()]}, 1); } else { - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![as_prev_commitment_tx[0].clone()]}, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![as_prev_commitment_tx[0].clone()]}, 1); } check_closed_broadcast!(nodes[0], false); @@ -7253,7 +7253,7 @@ fn do_test_sweep_outbound_htlc_failure_update(revoked: bool, local: bool) { let mut timeout_tx = Vec::new(); if local { // We fail dust-HTLC 1 by broadcast of local commitment tx - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![as_commitment_tx[0].clone()]}, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![as_commitment_tx[0].clone()]}, 1); check_closed_broadcast!(nodes[0], false); check_added_monitors!(nodes[0], 1); assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0); @@ -7264,13 +7264,13 @@ fn do_test_sweep_outbound_htlc_failure_update(revoked: bool, local: bool) { // We fail non-dust-HTLC 2 by broadcast of local HTLC-timeout tx on local commitment tx let header_2 = BlockHeader { version: 0x20000000, prev_blockhash: parent_hash, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0); - nodes[0].block_notifier.block_connected(&Block { header: header_2, txdata: vec![timeout_tx[0].clone()]}, 7); + connect_block(&nodes[0], &Block { header: header_2, txdata: vec![timeout_tx[0].clone()]}, 7); let header_3 = BlockHeader { version: 0x20000000, prev_blockhash: header_2.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1, 8, true, header_3.block_hash()); expect_payment_failed!(nodes[0], non_dust_hash, true); } else { // We fail dust-HTLC 1 by broadcast of remote commitment tx. If revoked, fail also non-dust HTLC - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![bs_commitment_tx[0].clone()]}, 1); + connect_block(&nodes[0], &Block { header, txdata: vec![bs_commitment_tx[0].clone()]}, 1); check_closed_broadcast!(nodes[0], false); check_added_monitors!(nodes[0], 1); assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0); @@ -7281,7 +7281,7 @@ fn do_test_sweep_outbound_htlc_failure_update(revoked: bool, local: bool) { expect_payment_failed!(nodes[0], dust_hash, true); assert_eq!(timeout_tx[0].input[0].witness.last().unwrap().len(), ACCEPTED_HTLC_SCRIPT_WEIGHT); // We fail non-dust-HTLC 2 by broadcast of local timeout tx on remote commitment tx - nodes[0].block_notifier.block_connected(&Block { header: header_2, txdata: vec![timeout_tx[0].clone()]}, 7); + connect_block(&nodes[0], &Block { header: header_2, txdata: vec![timeout_tx[0].clone()]}, 7); assert_eq!(nodes[0].node.get_and_clear_pending_events().len(), 0); let header_3 = BlockHeader { version: 0x20000000, prev_blockhash: header_2.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1, 8, true, header_3.block_hash()); @@ -7571,7 +7571,7 @@ fn test_data_loss_protect() { check_spends!(node_txn[0], chan.3); assert_eq!(node_txn[0].output.len(), 2); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42}; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![node_txn[0].clone()]}, 0); + connect_block(&nodes[0], &Block { header, txdata: vec![node_txn[0].clone()]}, 0); connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1, 0, true, header.block_hash()); let spend_txn = check_spendable_outputs!(nodes[0], 1, node_cfgs[0].keys_manager, 100000); assert_eq!(spend_txn.len(), 1); @@ -7725,7 +7725,7 @@ fn test_bump_penalty_txn_on_revoked_commitment() { // Actually revoke tx by claiming a HTLC claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage, 3_000_000); let header = BlockHeader { version: 0x20000000, prev_blockhash: header_114, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_txn[0].clone()] }, 115); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_txn[0].clone()] }, 115); check_added_monitors!(nodes[1], 1); // One or more justice tx should have been broadcast, check it @@ -7817,7 +7817,7 @@ fn test_bump_penalty_txn_on_revoked_htlcs() { let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; // B will generate both revoked HTLC-timeout/HTLC-preimage txn from revoked commitment tx - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![revoked_local_txn[0].clone()] }, 1); check_closed_broadcast!(nodes[1], false); check_added_monitors!(nodes[1], 1); @@ -7841,10 +7841,10 @@ fn test_bump_penalty_txn_on_revoked_htlcs() { // Broadcast set of revoked txn on A let header_128 = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header: header_128, txdata: vec![revoked_local_txn[0].clone()] }, 128); + connect_block(&nodes[0], &Block { header: header_128, txdata: vec![revoked_local_txn[0].clone()] }, 128); expect_pending_htlcs_forwardable_ignore!(nodes[0]); let header_129 = BlockHeader { version: 0x20000000, prev_blockhash: header_128.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header: header_129, txdata: vec![revoked_htlc_txn[0].clone(), revoked_htlc_txn[1].clone()] }, 129); + connect_block(&nodes[0], &Block { header: header_129, txdata: vec![revoked_htlc_txn[0].clone(), revoked_htlc_txn[1].clone()] }, 129); let first; let feerate_1; let penalty_txn; @@ -7895,9 +7895,9 @@ fn test_bump_penalty_txn_on_revoked_htlcs() { // Connect one more block to see if bumped penalty are issued for HTLC txn let header_130 = BlockHeader { version: 0x20000000, prev_blockhash: header_129.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header: header_130, txdata: penalty_txn }, 130); + connect_block(&nodes[0], &Block { header: header_130, txdata: penalty_txn }, 130); let header_131 = BlockHeader { version: 0x20000000, prev_blockhash: header_130.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header: header_131, txdata: Vec::new() }, 131); + connect_block(&nodes[0], &Block { header: header_131, txdata: Vec::new() }, 131); { let mut node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap(); assert_eq!(node_txn.len(), 2); // 2 bumped penalty txn on revoked commitment tx @@ -7936,7 +7936,7 @@ fn test_bump_penalty_txn_on_revoked_htlcs() { }; // Broadcast claim txn and confirm blocks to avoid further bumps on this outputs let header_145 = BlockHeader { version: 0x20000000, prev_blockhash: header_144, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header: header_145, txdata: node_txn }, 145); + connect_block(&nodes[0], &Block { header: header_145, txdata: node_txn }, 145); connect_blocks(&nodes[0], 20, 145, true, header_145.block_hash()); { let mut node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap(); @@ -7980,7 +7980,7 @@ fn test_bump_penalty_txn_on_remote_commitment() { // Claim a HTLC without revocation (provide B monitor with preimage) nodes[1].node.claim_funds(payment_preimage, &None, 3_000_000); let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![remote_txn[0].clone()] }, 1); + connect_block(&nodes[1], &Block { header, txdata: vec![remote_txn[0].clone()] }, 1); check_added_monitors!(nodes[1], 2); // One or more claim tx should have been broadcast, check it @@ -8099,7 +8099,7 @@ fn test_set_outpoints_partial_claiming() { // Connect blocks on node A commitment transaction let header = BlockHeader { version: 0x20000000, prev_blockhash: prev_header_100, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![remote_txn[0].clone()] }, 101); + connect_block(&nodes[0], &Block { header, txdata: vec![remote_txn[0].clone()] }, 101); check_closed_broadcast!(nodes[0], false); check_added_monitors!(nodes[0], 1); // Verify node A broadcast tx claiming both HTLCs @@ -8132,7 +8132,7 @@ fn test_set_outpoints_partial_claiming() { // Broadcast partial claim on node A, should regenerate a claiming tx with HTLC dropped let header = BlockHeader { version: 0x20000000, prev_blockhash: header.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![partial_claim_tx.clone()] }, 102); + connect_block(&nodes[0], &Block { header, txdata: vec![partial_claim_tx.clone()] }, 102); { let mut node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap(); assert_eq!(node_txn.len(), 1); @@ -8143,7 +8143,7 @@ fn test_set_outpoints_partial_claiming() { nodes[0].node.get_and_clear_pending_msg_events(); // Disconnect last block on node A, should regenerate a claiming tx with HTLC dropped - nodes[0].block_notifier.block_disconnected(&header, 102); + disconnect_block(&nodes[0], &header, 102); { let mut node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap(); assert_eq!(node_txn.len(), 1); @@ -8153,7 +8153,7 @@ fn test_set_outpoints_partial_claiming() { } //// Disconnect one more block and then reconnect multiple no transaction should be generated - nodes[0].block_notifier.block_disconnected(&header, 101); + disconnect_block(&nodes[0], &header, 101); connect_blocks(&nodes[1], 15, 101, false, prev_header_100); { let mut node_txn = nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap(); @@ -8218,7 +8218,7 @@ fn test_bump_txn_sanitize_tracking_maps() { expect_pending_htlcs_forwardable_ignore!(nodes[0]); let header_129 = BlockHeader { version: 0x20000000, prev_blockhash: header_128, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header: header_129, txdata: vec![revoked_local_txn[0].clone()] }, 129); + connect_block(&nodes[0], &Block { header: header_129, txdata: vec![revoked_local_txn[0].clone()] }, 129); check_closed_broadcast!(nodes[0], false); check_added_monitors!(nodes[0], 1); let penalty_txn = { @@ -8232,7 +8232,7 @@ fn test_bump_txn_sanitize_tracking_maps() { penalty_txn }; let header_130 = BlockHeader { version: 0x20000000, prev_blockhash: header_129.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }; - nodes[0].block_notifier.block_connected(&Block { header: header_130, txdata: penalty_txn }, 130); + connect_block(&nodes[0], &Block { header: header_130, txdata: penalty_txn }, 130); connect_blocks(&nodes[0], 5, 130, false, header_130.block_hash()); { let monitors = nodes[0].chan_monitor.simple_monitor.monitors.lock().unwrap(); diff --git a/lightning/src/ln/onion_route_tests.rs b/lightning/src/ln/onion_route_tests.rs index 2c6c3f218..f4ad80903 100644 --- a/lightning/src/ln/onion_route_tests.rs +++ b/lightning/src/ln/onion_route_tests.rs @@ -64,7 +64,7 @@ fn run_onion_failure_test_with_fail_intercept(_name: &str, test_case: txdata: vec![], }; for ix in 0..nodes.len() { - nodes[ix].block_notifier.block_connected(&block, 1); + connect_block(&nodes[ix], &block, 1); } macro_rules! expect_event { @@ -448,7 +448,7 @@ fn test_onion_failure() { txdata: vec![], }; - nodes[1].block_notifier.block_connected(&block, height); + connect_block(&nodes[1], &block, height); }, ||{}, true, Some(UPDATE|14), Some(msgs::HTLCFailChannelUpdate::ChannelUpdateMessage{msg: ChannelUpdate::dummy()})); run_onion_failure_test("unknown_payment_hash", 2, &nodes, &route, &payment_hash, |_| {}, || { @@ -462,7 +462,7 @@ fn test_onion_failure() { txdata: vec![], }; - nodes[2].block_notifier.block_connected(&block, height); + connect_block(&nodes[2], &block, height); }, || {}, true, Some(17), None); run_onion_failure_test("final_incorrect_cltv_expiry", 1, &nodes, &route, &payment_hash, |_| {}, || { diff --git a/lightning/src/ln/reorg_tests.rs b/lightning/src/ln/reorg_tests.rs index d960727dd..e1ff1665f 100644 --- a/lightning/src/ln/reorg_tests.rs +++ b/lightning/src/ln/reorg_tests.rs @@ -61,7 +61,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) { check_spends!(node_1_commitment_txn[1], node_1_commitment_txn[0]); // Give node 2 node 1's transactions and get its response (claiming the HTLC instead). - nodes[2].block_notifier.block_connected(&Block { header, txdata: node_1_commitment_txn.clone() }, CHAN_CONFIRM_DEPTH + 1); + connect_block(&nodes[2], &Block { header, txdata: node_1_commitment_txn.clone() }, CHAN_CONFIRM_DEPTH + 1); check_added_monitors!(nodes[2], 1); check_closed_broadcast!(nodes[2], false); // We should get a BroadcastChannelUpdate (and *only* a BroadcstChannelUpdate) let node_2_commitment_txn = nodes[2].tx_broadcaster.txn_broadcasted.lock().unwrap(); @@ -72,7 +72,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) { check_spends!(node_2_commitment_txn[0], node_1_commitment_txn[0]); // Confirm node 1's commitment txn (and HTLC-Timeout) on node 1 - nodes[1].block_notifier.block_connected(&Block { header, txdata: node_1_commitment_txn.clone() }, CHAN_CONFIRM_DEPTH + 1); + connect_block(&nodes[1], &Block { header, txdata: node_1_commitment_txn.clone() }, CHAN_CONFIRM_DEPTH + 1); // ...but return node 1's commitment tx in case claim is set and we're preparing to reorg vec![node_1_commitment_txn[0].clone(), node_2_commitment_txn[0].clone()] @@ -85,7 +85,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) { check_spends!(node_2_commitment_txn[1], node_2_commitment_txn[0]); // Give node 1 node 2's commitment transaction and get its response (timing the HTLC out) - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![node_2_commitment_txn[0].clone()] }, CHAN_CONFIRM_DEPTH + 1); + connect_block(&nodes[1], &Block { header, txdata: vec![node_2_commitment_txn[0].clone()] }, CHAN_CONFIRM_DEPTH + 1); let node_1_commitment_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap(); assert_eq!(node_1_commitment_txn.len(), 3); // ChannelMonitor: 1 offered HTLC-Timeout, ChannelManger: 1 local commitment tx, 1 Offered HTLC-Timeout assert_eq!(node_1_commitment_txn[1].output.len(), 2); // to-local and Offered HTLC (to-remote is dust) @@ -94,7 +94,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) { check_spends!(node_1_commitment_txn[0], node_2_commitment_txn[0]); // Confirm node 2's commitment txn (and node 1's HTLC-Timeout) on node 1 - nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![node_2_commitment_txn[0].clone(), node_1_commitment_txn[0].clone()] }, CHAN_CONFIRM_DEPTH + 1); + connect_block(&nodes[1], &Block { header, txdata: vec![node_2_commitment_txn[0].clone(), node_1_commitment_txn[0].clone()] }, CHAN_CONFIRM_DEPTH + 1); // ...but return node 2's commitment tx (and claim) in case claim is set and we're preparing to reorg node_2_commitment_txn }; @@ -110,7 +110,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) { header: BlockHeader { version: 0x20000000, prev_blockhash: block.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - nodes[1].block_notifier.block_connected(&block, i); + connect_block(&nodes[1], &block, i); blocks.push(block.clone()); } check_added_monitors!(nodes[1], 0); @@ -119,14 +119,14 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) { if claim { // Now reorg back to CHAN_CONFIRM_DEPTH and confirm node 2's broadcasted transactions: for (height, block) in (CHAN_CONFIRM_DEPTH + 1..CHAN_CONFIRM_DEPTH + ANTI_REORG_DELAY - 1).zip(blocks.iter()).rev() { - nodes[1].block_notifier.block_disconnected(&block.header, height); + disconnect_block(&nodes[1], &block.header, height); } block = Block { header: BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: claim_txn, }; - nodes[1].block_notifier.block_connected(&block, CHAN_CONFIRM_DEPTH + 1); + connect_block(&nodes[1], &block, CHAN_CONFIRM_DEPTH + 1); // ChannelManager only polls ManyChannelMonitor::get_and_clear_pending_monitor_events when we // probe it for events, so we probe non-message events here (which should still end up empty): @@ -137,7 +137,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) { header: BlockHeader { version: 0x20000000, prev_blockhash: block.block_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 }, txdata: vec![], }; - nodes[1].block_notifier.block_connected(&block, CHAN_CONFIRM_DEPTH + ANTI_REORG_DELAY); + connect_block(&nodes[1], &block, CHAN_CONFIRM_DEPTH + ANTI_REORG_DELAY); expect_pending_htlcs_forwardable!(nodes[1]); }