Replace use of ChainWatchInterface with WatchEvent
[rust-lightning] / lightning / src / ln / functional_test_utils.rs
index f8f324c9b92ed02f16133da86d2f6b37c34dea2c..c164cd6bbe5604f0eab7739c51943ba810e8b5d8 100644 (file)
@@ -10,6 +10,7 @@
 //! A bunch of useful utilities for building networks of nodes and exchanging messages between
 //! nodes for functional tests.
 
+use chain;
 use chain::chaininterface;
 use chain::transaction::OutPoint;
 use ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentPreimage, PaymentHash, PaymentSecret, PaymentSendFailure};
@@ -80,9 +81,29 @@ pub fn connect_blocks<'a, 'b, 'c, 'd>(node: &'a Node<'b, 'c, 'd>, depth: u32, he
 }
 
 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)
+       use chain::WatchEventProvider;
+       use chain::chaininterface::ChainListener;
+
+       let watch_events = node.chan_monitor.simple_monitor.release_pending_watch_events();
+       process_chain_watch_events(&watch_events);
+
+       let txdata: Vec<_> = block.txdata.iter().enumerate().collect();
+       loop {
+               node.chan_monitor.simple_monitor.block_connected(&block.header, &txdata, height);
+
+               let watch_events = node.chan_monitor.simple_monitor.release_pending_watch_events();
+               process_chain_watch_events(&watch_events);
+
+               if watch_events.is_empty() {
+                       break;
+               }
+       }
+
+       node.node.block_connected(&block.header, &txdata, height);
 }
 
+fn process_chain_watch_events(_events: &Vec<chain::WatchEvent>) {}
+
 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)
 }