X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Freorg_tests.rs;h=3481e8d6cd9f39b60e4b186d8cf403f63ebc6afd;hb=1e26a2bc197207be512d905b05595492242b5f90;hp=507dc34dfbe44a66a9505adb7e7aba60fca3951c;hpb=3b3713fdde4c0bea587f8e9bca396d81fb5a7ac9;p=rust-lightning diff --git a/lightning/src/ln/reorg_tests.rs b/lightning/src/ln/reorg_tests.rs index 507dc34d..3481e8d6 100644 --- a/lightning/src/ln/reorg_tests.rs +++ b/lightning/src/ln/reorg_tests.rs @@ -9,15 +9,15 @@ //! Further functional tests which test blockchain reorganizations. -use chain::channelmonitor::{ANTI_REORG_DELAY, ChannelMonitor}; -use chain::transaction::OutPoint; -use chain::{Confirm, Watch}; -use ln::channelmanager::{self, ChannelManager, ChannelManagerReadArgs}; -use ln::msgs::ChannelMessageHandler; -use util::enforcing_trait_impls::EnforcingSigner; -use util::events::{Event, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination}; -use util::test_utils; -use util::ser::{ReadableArgs, Writeable}; +use crate::chain::channelmonitor::{ANTI_REORG_DELAY, ChannelMonitor}; +use crate::chain::transaction::OutPoint; +use crate::chain::{ChannelMonitorUpdateStatus, Confirm, Watch}; +use crate::ln::channelmanager::{self, ChannelManager, ChannelManagerReadArgs}; +use crate::ln::msgs::ChannelMessageHandler; +use crate::util::enforcing_trait_impls::EnforcingSigner; +use crate::util::events::{Event, MessageSendEvent, MessageSendEventsProvider, ClosureReason, HTLCDestination}; +use crate::util::test_utils; +use crate::util::ser::{ReadableArgs, Writeable}; use bitcoin::blockdata::block::{Block, BlockHeader}; use bitcoin::blockdata::script::Builder; @@ -25,12 +25,12 @@ use bitcoin::blockdata::opcodes; use bitcoin::hash_types::BlockHash; use bitcoin::secp256k1::Secp256k1; -use prelude::*; +use crate::prelude::*; use core::mem; use bitcoin::hashes::Hash; use bitcoin::TxMerkleNode; -use ln::functional_test_utils::*; +use crate::ln::functional_test_utils::*; fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) { // Our on-chain HTLC-claim learning has a few properties worth testing: @@ -267,7 +267,7 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_ let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); let persister: test_utils::TestPersister; let new_chain_monitor: test_utils::TestChainMonitor; - let nodes_0_deserialized: ChannelManager; + let nodes_0_deserialized: ChannelManager<&test_utils::TestChainMonitor, &test_utils::TestBroadcaster, &test_utils::TestKeysInterface, &test_utils::TestFeeEstimator, &test_utils::TestLogger>; let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs); *nodes[0].connect_style.borrow_mut() = connect_style; @@ -275,7 +275,7 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_ let channel_state = nodes[0].node.channel_state.lock().unwrap(); assert_eq!(channel_state.by_id.len(), 1); - assert_eq!(channel_state.short_to_chan_info.len(), 2); + assert_eq!(nodes[0].node.short_to_chan_info.read().unwrap().len(), 2); mem::drop(channel_state); if !reorg_after_reload { @@ -295,7 +295,7 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_ { let channel_state = nodes[0].node.channel_state.lock().unwrap(); assert_eq!(channel_state.by_id.len(), 0); - assert_eq!(channel_state.short_to_chan_info.len(), 0); + assert_eq!(nodes[0].node.short_to_chan_info.read().unwrap().len(), 0); } } @@ -321,7 +321,7 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_ nodes_0_deserialized = { let mut channel_monitors = HashMap::new(); channel_monitors.insert(chan_0_monitor.get_funding_txo().0, &mut chan_0_monitor); - <(BlockHash, ChannelManager)>::read( &mut nodes_0_read, ChannelManagerReadArgs { default_config: *nodes[0].node.get_current_default_configuration(), @@ -342,7 +342,8 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_ nodes[0].tx_broadcaster.txn_broadcasted.lock().unwrap().clear(); } - nodes[0].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0.clone(), chan_0_monitor).unwrap(); + assert_eq!(nodes[0].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0.clone(), chan_0_monitor), + ChannelMonitorUpdateStatus::Completed); check_added_monitors!(nodes[0], 1); } @@ -363,7 +364,7 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool, use_funding_ { let channel_state = nodes[0].node.channel_state.lock().unwrap(); assert_eq!(channel_state.by_id.len(), 0); - assert_eq!(channel_state.short_to_chan_info.len(), 0); + assert_eq!(nodes[0].node.short_to_chan_info.read().unwrap().len(), 0); } } // With expect_channel_force_closed set the TestChainMonitor will enforce that the next update