Rename ChannelMonitor::write_for_disk --> serialize_for_disk
[rust-lightning] / lightning / src / ln / functional_test_utils.rs
index 871854ce63e06ae405c0c859f286214c8adde245..2784f93495669dc704cda8caf03a58557dacb920 100644 (file)
@@ -94,6 +94,7 @@ pub struct TestChanMonCfg {
        pub tx_broadcaster: test_utils::TestBroadcaster,
        pub fee_estimator: test_utils::TestFeeEstimator,
        pub chain_source: test_utils::TestChainSource,
+       pub persister: test_utils::TestPersister,
        pub logger: test_utils::TestLogger,
 }
 
@@ -169,7 +170,7 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
                                let old_monitors = self.chain_monitor.chain_monitor.monitors.lock().unwrap();
                                for (_, old_monitor) in old_monitors.iter() {
                                        let mut w = test_utils::TestVecWriter(Vec::new());
-                                       old_monitor.write_for_disk(&mut w).unwrap();
+                                       old_monitor.serialize_for_disk(&mut w).unwrap();
                                        let (_, deserialized_monitor) = <(BlockHash, ChannelMonitor<EnforcingChannelKeys>)>::read(
                                                &mut ::std::io::Cursor::new(&w.0)).unwrap();
                                        deserialized_monitors.push(deserialized_monitor);
@@ -197,8 +198,9 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
                                }).unwrap();
                        }
 
+                       let persister = test_utils::TestPersister::new();
                        let chain_source = test_utils::TestChainSource::new(Network::Testnet);
-                       let chain_monitor = test_utils::TestChainMonitor::new(Some(&chain_source), self.tx_broadcaster.clone(), &self.logger, &feeest);
+                       let chain_monitor = test_utils::TestChainMonitor::new(Some(&chain_source), self.tx_broadcaster.clone(), &self.logger, &feeest, &persister);
                        for deserialized_monitor in deserialized_monitors.drain(..) {
                                if let Err(_) = chain_monitor.watch_channel(deserialized_monitor.get_funding_txo().0, deserialized_monitor) {
                                        panic!();
@@ -247,6 +249,8 @@ macro_rules! get_revoke_commit_msgs {
        }
 }
 
+/// Get an specific event message from the pending events queue.
+#[macro_export]
 macro_rules! get_event_msg {
        ($node: expr, $event_type: path, $node_id: expr) => {
                {
@@ -308,6 +312,8 @@ macro_rules! get_local_commitment_txn {
        }
 }
 
+/// Check the error from attempting a payment.
+#[macro_export]
 macro_rules! unwrap_send_err {
        ($res: expr, $all_failed: expr, $type: pat, $check: expr) => {
                match &$res {
@@ -758,6 +764,8 @@ macro_rules! commitment_signed_dance {
        }
 }
 
+/// Get a payment preimage and hash.
+#[macro_export]
 macro_rules! get_payment_preimage_hash {
        ($node: expr) => {
                {
@@ -1115,7 +1123,8 @@ pub fn create_chanmon_cfgs(node_count: usize) -> Vec<TestChanMonCfg> {
                let fee_estimator = test_utils::TestFeeEstimator { sat_per_kw: 253 };
                let chain_source = test_utils::TestChainSource::new(Network::Testnet);
                let logger = test_utils::TestLogger::with_id(format!("node {}", i));
-               chan_mon_cfgs.push(TestChanMonCfg{ tx_broadcaster, fee_estimator, chain_source, logger });
+               let persister = test_utils::TestPersister::new();
+               chan_mon_cfgs.push(TestChanMonCfg{ tx_broadcaster, fee_estimator, chain_source, logger, persister });
        }
 
        chan_mon_cfgs
@@ -1127,7 +1136,7 @@ pub fn create_node_cfgs<'a>(node_count: usize, chanmon_cfgs: &'a Vec<TestChanMon
        for i in 0..node_count {
                let seed = [i as u8; 32];
                let keys_manager = test_utils::TestKeysInterface::new(&seed, Network::Testnet);
-               let chain_monitor = test_utils::TestChainMonitor::new(Some(&chanmon_cfgs[i].chain_source), &chanmon_cfgs[i].tx_broadcaster, &chanmon_cfgs[i].logger, &chanmon_cfgs[i].fee_estimator);
+               let chain_monitor = test_utils::TestChainMonitor::new(Some(&chanmon_cfgs[i].chain_source), &chanmon_cfgs[i].tx_broadcaster, &chanmon_cfgs[i].logger, &chanmon_cfgs[i].fee_estimator, &chanmon_cfgs[i].persister);
                nodes.push(NodeCfg { chain_source: &chanmon_cfgs[i].chain_source, logger: &chanmon_cfgs[i].logger, tx_broadcaster: &chanmon_cfgs[i].tx_broadcaster, fee_estimator: &chanmon_cfgs[i].fee_estimator, chain_monitor, keys_manager, node_seed: seed });
        }