Skip to content

Commit bcfe5f5

Browse files
committed
Replace BlockNotifier with Node in test utilities
Change confirm_transaction and connect_blocks to take a Node instead of a BlockNotifier. This is in preparation for signaling watch events back via a refactoring of ManyChannelMonitor and ChainWatchInterface.
1 parent 49d9219 commit bcfe5f5

File tree

3 files changed

+55
-52
lines changed

3 files changed

+55
-52
lines changed

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,11 +1747,11 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
17471747
};
17481748

17491749
if confirm_a_first {
1750-
confirm_transaction(&nodes[0].block_notifier, &funding_tx);
1750+
confirm_transaction(&nodes[0], &funding_tx);
17511751
nodes[1].node.handle_funding_locked(&nodes[0].node.get_our_node_id(), &get_event_msg!(nodes[0], MessageSendEvent::SendFundingLocked, nodes[1].node.get_our_node_id()));
17521752
} else {
17531753
assert!(!restore_b_before_conf);
1754-
confirm_transaction(&nodes[1].block_notifier, &funding_tx);
1754+
confirm_transaction(&nodes[1], &funding_tx);
17551755
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
17561756
}
17571757

@@ -1763,7 +1763,7 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
17631763
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
17641764

17651765
if !restore_b_before_conf {
1766-
confirm_transaction(&nodes[1].block_notifier, &funding_tx);
1766+
confirm_transaction(&nodes[1], &funding_tx);
17671767
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
17681768
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
17691769
}
@@ -1776,12 +1776,12 @@ fn do_during_funding_monitor_fail(confirm_a_first: bool, restore_b_before_conf:
17761776
let (channel_id, (announcement, as_update, bs_update)) = if !confirm_a_first {
17771777
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()));
17781778

1779-
confirm_transaction(&nodes[0].block_notifier, &funding_tx);
1779+
confirm_transaction(&nodes[0], &funding_tx);
17801780
let (funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[1], &nodes[0]);
17811781
(channel_id, create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &funding_locked))
17821782
} else {
17831783
if restore_b_before_conf {
1784-
confirm_transaction(&nodes[1].block_notifier, &funding_tx);
1784+
confirm_transaction(&nodes[1], &funding_tx);
17851785
}
17861786
let (funding_locked, channel_id) = create_chan_between_nodes_with_value_confirm_second(&nodes[0], &nodes[1]);
17871787
(channel_id, create_chan_between_nodes_with_value_b(&nodes[1], &nodes[0], &funding_locked))

lightning/src/ln/functional_test_utils.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ use std::mem;
3636
use std::collections::HashMap;
3737

3838
pub const CHAN_CONFIRM_DEPTH: u32 = 100;
39-
pub fn confirm_transaction<'a, 'b: 'a>(notifier: &'a chaininterface::BlockNotifierRef<'b>, tx: &Transaction) {
39+
40+
pub fn confirm_transaction<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, tx: &Transaction) {
41+
let notifier = &node.block_notifier;
4042
let dummy_tx = Transaction { version: 0, lock_time: 0, input: Vec::new(), output: Vec::new() };
4143
let dummy_tx_count = tx.version as usize;
4244
let mut block = Block {
@@ -54,7 +56,8 @@ pub fn confirm_transaction<'a, 'b: 'a>(notifier: &'a chaininterface::BlockNotifi
5456
}
5557
}
5658

57-
pub fn connect_blocks<'a, 'b>(notifier: &'a chaininterface::BlockNotifierRef<'b>, depth: u32, height: u32, parent: bool, prev_blockhash: BlockHash) -> BlockHash {
59+
pub fn connect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, depth: u32, height: u32, parent: bool, prev_blockhash: BlockHash) -> BlockHash {
60+
let notifier = &node.block_notifier;
5861
let mut block = Block {
5962
header: BlockHeader { version: 0x2000000, prev_blockhash: if parent { prev_blockhash } else { Default::default() }, merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 },
6063
txdata: vec![],
@@ -379,7 +382,7 @@ pub fn create_chan_between_nodes_with_value_init<'a, 'b, 'c>(node_a: &Node<'a, '
379382
}
380383

381384
pub fn create_chan_between_nodes_with_value_confirm_first<'a, 'b, 'c, 'd>(node_recv: &'a Node<'b, 'c, 'c>, node_conf: &'a Node<'b, 'c, 'd>, tx: &Transaction) {
382-
confirm_transaction(&node_conf.block_notifier, &tx);
385+
confirm_transaction(node_conf, tx);
383386
node_recv.node.handle_funding_locked(&node_conf.node.get_our_node_id(), &get_event_msg!(node_conf, MessageSendEvent::SendFundingLocked, node_recv.node.get_our_node_id()));
384387
}
385388

@@ -405,7 +408,7 @@ pub fn create_chan_between_nodes_with_value_confirm_second<'a, 'b, 'c>(node_recv
405408

406409
pub fn create_chan_between_nodes_with_value_confirm<'a, 'b, 'c, 'd>(node_a: &'a Node<'b, 'c, 'd>, node_b: &'a Node<'b, 'c, 'd>, tx: &Transaction) -> ((msgs::FundingLocked, msgs::AnnouncementSignatures), [u8; 32]) {
407410
create_chan_between_nodes_with_value_confirm_first(node_a, node_b, tx);
408-
confirm_transaction(&node_a.block_notifier, &tx);
411+
confirm_transaction(node_a, tx);
409412
create_chan_between_nodes_with_value_confirm_second(node_b, node_a)
410413
}
411414

0 commit comments

Comments
 (0)