X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fpayment_tests.rs;h=c22f4611c34438b80f3071de6635b9ae43410402;hb=a257906743d528c32c862b053b652d4b728aa990;hp=02a3185e1509778ba13d38daa9d205fcbe07c3f8;hpb=48d21bad7b0b8dc567ed0e4e3f55c62e48fcb422;p=rust-lightning diff --git a/lightning/src/ln/payment_tests.rs b/lightning/src/ln/payment_tests.rs index 02a3185e..c22f4611 100644 --- a/lightning/src/ln/payment_tests.rs +++ b/lightning/src/ln/payment_tests.rs @@ -11,29 +11,29 @@ //! serialization ordering between ChannelManager/ChannelMonitors and ensuring we can still retry //! payments thereafter. -use chain::{ChannelMonitorUpdateErr, Confirm, Listen, Watch}; -use chain::channelmonitor::{ANTI_REORG_DELAY, ChannelMonitor, LATENCY_GRACE_PERIOD_BLOCKS}; -use chain::transaction::OutPoint; -use chain::keysinterface::KeysInterface; -use ln::channel::EXPIRE_PREV_CONFIG_TICKS; -use ln::channelmanager::{self, BREAKDOWN_TIMEOUT, ChannelManager, ChannelManagerReadArgs, MPP_TIMEOUT_TICKS, MIN_CLTV_EXPIRY_DELTA, PaymentId, PaymentSendFailure}; -use ln::msgs; -use ln::msgs::ChannelMessageHandler; -use routing::router::{PaymentParameters, get_route}; -use util::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider}; -use util::test_utils; -use util::errors::APIError; -use util::enforcing_trait_impls::EnforcingSigner; -use util::ser::{ReadableArgs, Writeable}; -use io; +use crate::chain::{ChannelMonitorUpdateStatus, Confirm, Listen, Watch}; +use crate::chain::channelmonitor::{ANTI_REORG_DELAY, ChannelMonitor, LATENCY_GRACE_PERIOD_BLOCKS}; +use crate::chain::transaction::OutPoint; +use crate::chain::keysinterface::KeysInterface; +use crate::ln::channel::EXPIRE_PREV_CONFIG_TICKS; +use crate::ln::channelmanager::{self, BREAKDOWN_TIMEOUT, ChannelManager, ChannelManagerReadArgs, MPP_TIMEOUT_TICKS, MIN_CLTV_EXPIRY_DELTA, PaymentId, PaymentSendFailure}; +use crate::ln::msgs; +use crate::ln::msgs::ChannelMessageHandler; +use crate::routing::router::{PaymentParameters, get_route}; +use crate::util::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider}; +use crate::util::test_utils; +use crate::util::errors::APIError; +use crate::util::enforcing_trait_impls::EnforcingSigner; +use crate::util::ser::{ReadableArgs, Writeable}; +use crate::io; use bitcoin::{Block, BlockHeader, BlockHash, TxMerkleNode}; use bitcoin::hashes::Hash; use bitcoin::network::constants::Network; -use prelude::*; +use crate::prelude::*; -use ln::functional_test_utils::*; +use crate::ln::functional_test_utils::*; #[test] fn retry_single_path_payment() { @@ -436,7 +436,8 @@ fn do_retry_with_no_persist(confirm_before_reload: bool) { nodes_0_deserialized = nodes_0_deserialized_tmp; assert!(nodes_0_read.is_empty()); - assert!(nodes[0].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0, chan_0_monitor).is_ok()); + assert_eq!(nodes[0].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0, chan_0_monitor), + ChannelMonitorUpdateStatus::Completed); nodes[0].node = &nodes_0_deserialized; check_added_monitors!(nodes[0], 1); @@ -643,10 +644,12 @@ fn do_test_completed_payment_not_retryable_on_reload(use_dust: bool) { $chan_manager = nodes_0_deserialized_tmp; assert!(nodes_0_read.is_empty()); - assert!(nodes[0].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0, chan_0_monitor).is_ok()); + assert_eq!(nodes[0].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0, chan_0_monitor), + ChannelMonitorUpdateStatus::Completed); if !chan_1_monitor_serialized.0.is_empty() { let funding_txo = chan_1_monitor.as_ref().unwrap().get_funding_txo().0; - assert!(nodes[0].chain_monitor.watch_channel(funding_txo, chan_1_monitor.unwrap()).is_ok()); + assert_eq!(nodes[0].chain_monitor.watch_channel(funding_txo, chan_1_monitor.unwrap()), + ChannelMonitorUpdateStatus::Completed); } nodes[0].node = &$chan_manager; check_added_monitors!(nodes[0], if !chan_1_monitor_serialized.0.is_empty() { 2 } else { 1 }); @@ -853,10 +856,10 @@ fn do_test_dup_htlc_onchain_fails_on_reload(persist_manager_post_event: bool, co } // Now connect the HTLC claim transaction with the ChainMonitor-generated ChannelMonitor update - // returning TemporaryFailure. This should cause the claim event to never make its way to the + // returning InProgress. This should cause the claim event to never make its way to the // ChannelManager. chanmon_cfgs[0].persister.chain_sync_monitor_persistences.lock().unwrap().clear(); - chanmon_cfgs[0].persister.set_update_ret(Err(ChannelMonitorUpdateErr::TemporaryFailure)); + chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress); if payment_timeout { connect_blocks(&nodes[0], 1); @@ -881,7 +884,7 @@ fn do_test_dup_htlc_onchain_fails_on_reload(persist_manager_post_event: bool, co // Now persist the ChannelMonitor and inform the ChainMonitor that we're done, generating the // payment sent event. - chanmon_cfgs[0].persister.set_update_ret(Ok(())); + chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::Completed); let mut chan_0_monitor_serialized = test_utils::TestVecWriter(Vec::new()); get_monitor!(nodes[0], chan_id).write(&mut chan_0_monitor_serialized).unwrap(); for update in mon_updates { @@ -925,7 +928,8 @@ fn do_test_dup_htlc_onchain_fails_on_reload(persist_manager_post_event: bool, co }; nodes_0_deserialized = nodes_0_deserialized_tmp; - assert!(nodes[0].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0, chan_0_monitor).is_ok()); + assert_eq!(nodes[0].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0, chan_0_monitor), + ChannelMonitorUpdateStatus::Completed); check_added_monitors!(nodes[0], 1); nodes[0].node = &nodes_0_deserialized; @@ -1015,7 +1019,8 @@ fn test_fulfill_restart_failure() { }; nodes_1_deserialized = nodes_1_deserialized_tmp; - assert!(nodes[1].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0, chan_0_monitor).is_ok()); + assert_eq!(nodes[1].chain_monitor.watch_channel(chan_0_monitor.get_funding_txo().0, chan_0_monitor), + ChannelMonitorUpdateStatus::Completed); check_added_monitors!(nodes[1], 1); nodes[1].node = &nodes_1_deserialized;