X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fpriv_short_conf_tests.rs;h=313d84c53f86f40e0c6ae28bf0a54826a297ddf7;hb=ba1349982ba28657c9e2d03a5b02c3ecc054b5cc;hp=30d6eccd481e66fd9fd80377b1a900b3ed970160;hpb=7b2537bfcbf4a9c6d7ba78ab38eafeb4f54f2fa0;p=rust-lightning diff --git a/lightning/src/ln/priv_short_conf_tests.rs b/lightning/src/ln/priv_short_conf_tests.rs index 30d6eccd..313d84c5 100644 --- a/lightning/src/ln/priv_short_conf_tests.rs +++ b/lightning/src/ln/priv_short_conf_tests.rs @@ -13,6 +13,7 @@ use crate::chain::ChannelMonitorUpdateStatus; use crate::chain::keysinterface::NodeSigner; +use crate::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider}; use crate::ln::channelmanager::{ChannelManager, MIN_CLTV_EXPIRY_DELTA, PaymentId}; use crate::routing::gossip::RoutingFees; use crate::routing::router::{PaymentParameters, RouteHint, RouteHintHop}; @@ -20,7 +21,6 @@ use crate::ln::features::ChannelTypeFeatures; use crate::ln::msgs; use crate::ln::msgs::{ChannelMessageHandler, RoutingMessageHandler, ChannelUpdate, ErrorAction}; use crate::ln::wire::Encode; -use crate::util::events::{ClosureReason, Event, HTLCDestination, MessageSendEvent, MessageSendEventsProvider}; use crate::util::config::UserConfig; use crate::util::ser::Writeable; use crate::util::test_utils; @@ -362,7 +362,10 @@ fn test_inbound_scid_privacy() { check_added_monitors!(nodes[2], 1); let cs_funding_signed = get_event_msg!(nodes[2], MessageSendEvent::SendFundingSigned, nodes[1].node.get_our_node_id()); + expect_channel_pending_event(&nodes[2], &nodes[1].node.get_our_node_id()); + nodes[1].node.handle_funding_signed(&nodes[2].node.get_our_node_id(), &cs_funding_signed); + expect_channel_pending_event(&nodes[1], &nodes[2].node.get_our_node_id()); check_added_monitors!(nodes[1], 1); let conf_height = core::cmp::max(nodes[1].best_block_info().1 + 1, nodes[2].best_block_info().1 + 1); @@ -423,7 +426,7 @@ fn test_inbound_scid_privacy() { nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]); commitment_signed_dance!(nodes[1], nodes[0], payment_event.commitment_msg, true, true); - nodes[1].logger.assert_log_regex("lightning::ln::channelmanager".to_string(), regex::Regex::new(r"Refusing to forward over real channel SCID as our counterparty requested").unwrap(), 1); + nodes[1].logger.assert_log_regex("lightning::ln::channelmanager", regex::Regex::new(r"Refusing to forward over real channel SCID as our counterparty requested").unwrap(), 1); let mut updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); nodes[0].node.handle_update_fail_htlc(&nodes[1].node.get_our_node_id(), &updates.update_fail_htlcs[0]); @@ -599,6 +602,7 @@ fn test_0conf_channel_with_async_monitor() { let channel_id = funding_output.to_channel_id(); nodes[1].chain_monitor.complete_sole_pending_chan_update(&channel_id); + expect_channel_pending_event(&nodes[1], &nodes[0].node.get_our_node_id()); let bs_signed_locked = nodes[1].node.get_and_clear_pending_msg_events(); assert_eq!(bs_signed_locked.len(), 2); @@ -624,6 +628,22 @@ fn test_0conf_channel_with_async_monitor() { assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty()); nodes[0].chain_monitor.complete_sole_pending_chan_update(&channel_id); + + let events = nodes[0].node.get_and_clear_pending_events(); + assert_eq!(events.len(), 2); + match events[0] { + crate::events::Event::ChannelPending { ref counterparty_node_id, .. } => { + assert_eq!(nodes[1].node.get_our_node_id(), *counterparty_node_id); + }, + _ => panic!("Unexpected event"), + } + match events[1] { + crate::events::Event::ChannelReady { ref counterparty_node_id, .. } => { + assert_eq!(nodes[1].node.get_our_node_id(), *counterparty_node_id); + }, + _ => panic!("Unexpected event"), + } + let as_locked_update = nodes[0].node.get_and_clear_pending_msg_events(); // Note that the funding transaction is actually released when @@ -638,7 +658,6 @@ fn test_0conf_channel_with_async_monitor() { } _ => panic!("Unexpected event"), } - expect_channel_ready_event(&nodes[0], &nodes[1].node.get_our_node_id()); expect_channel_ready_event(&nodes[1], &nodes[0].node.get_our_node_id()); let bs_channel_update = get_event_msg!(nodes[1], MessageSendEvent::SendChannelUpdate, nodes[0].node.get_our_node_id());