@@ -693,6 +693,61 @@ pub fn create_announced_chan_between_nodes_with_value<'a, 'b, 'c, 'd>(nodes: &'a
693
693
( chan_announcement. 1 , chan_announcement. 2 , chan_announcement. 3 , chan_announcement. 4 )
694
694
}
695
695
696
+ pub fn create_unannounced_chan_between_nodes_with_value < ' a , ' b , ' c , ' d > ( nodes : & ' a Vec < Node < ' b , ' c , ' d > > , a : usize , b : usize , channel_value : u64 , push_msat : u64 , a_flags : InitFeatures , b_flags : InitFeatures ) -> ( msgs:: FundingLocked , Transaction ) {
697
+ let mut no_announce_cfg = test_default_channel_config ( ) ;
698
+ no_announce_cfg. channel_options . announced_channel = false ;
699
+ nodes[ a] . node . create_channel ( nodes[ b] . node . get_our_node_id ( ) , channel_value, push_msat, 42 , Some ( no_announce_cfg) ) . unwrap ( ) ;
700
+ let open_channel = get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendOpenChannel , nodes[ b] . node. get_our_node_id( ) ) ;
701
+ nodes[ b] . node . handle_open_channel ( & nodes[ a] . node . get_our_node_id ( ) , a_flags, & open_channel) ;
702
+ let accept_channel = get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendAcceptChannel , nodes[ a] . node. get_our_node_id( ) ) ;
703
+ nodes[ a] . node . handle_accept_channel ( & nodes[ b] . node . get_our_node_id ( ) , b_flags, & accept_channel) ;
704
+
705
+ let ( temporary_channel_id, tx, _) = create_funding_transaction ( & nodes[ a] , channel_value, 42 ) ;
706
+ nodes[ a] . node . funding_transaction_generated ( & temporary_channel_id, tx. clone ( ) ) . unwrap ( ) ;
707
+ nodes[ b] . node . handle_funding_created ( & nodes[ a] . node . get_our_node_id ( ) , & get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendFundingCreated , nodes[ b] . node. get_our_node_id( ) ) ) ;
708
+ check_added_monitors ! ( nodes[ b] , 1 ) ;
709
+
710
+ let cs_funding_signed = get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendFundingSigned , nodes[ a] . node. get_our_node_id( ) ) ;
711
+ nodes[ a] . node . handle_funding_signed ( & nodes[ b] . node . get_our_node_id ( ) , & cs_funding_signed) ;
712
+ check_added_monitors ! ( nodes[ a] , 1 ) ;
713
+
714
+ let conf_height = core:: cmp:: max ( nodes[ a] . best_block_info ( ) . 1 + 1 , nodes[ b] . best_block_info ( ) . 1 + 1 ) ;
715
+ confirm_transaction_at ( & nodes[ a] , & tx, conf_height) ;
716
+ connect_blocks ( & nodes[ a] , CHAN_CONFIRM_DEPTH - 1 ) ;
717
+ confirm_transaction_at ( & nodes[ b] , & tx, conf_height) ;
718
+ connect_blocks ( & nodes[ b] , CHAN_CONFIRM_DEPTH - 1 ) ;
719
+ let as_funding_locked = get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendFundingLocked , nodes[ b] . node. get_our_node_id( ) ) ;
720
+ nodes[ a] . node . handle_funding_locked ( & nodes[ b] . node . get_our_node_id ( ) , & get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendFundingLocked , nodes[ a] . node. get_our_node_id( ) ) ) ;
721
+ let as_update = get_event_msg ! ( nodes[ a] , MessageSendEvent :: SendChannelUpdate , nodes[ b] . node. get_our_node_id( ) ) ;
722
+ nodes[ b] . node . handle_funding_locked ( & nodes[ a] . node . get_our_node_id ( ) , & as_funding_locked) ;
723
+ let bs_update = get_event_msg ! ( nodes[ b] , MessageSendEvent :: SendChannelUpdate , nodes[ a] . node. get_our_node_id( ) ) ;
724
+
725
+ nodes[ a] . node . handle_channel_update ( & nodes[ b] . node . get_our_node_id ( ) , & bs_update) ;
726
+ nodes[ b] . node . handle_channel_update ( & nodes[ a] . node . get_our_node_id ( ) , & as_update) ;
727
+
728
+ let mut found_a = false ;
729
+ for chan in nodes[ a] . node . list_usable_channels ( ) {
730
+ if chan. channel_id == as_funding_locked. channel_id {
731
+ assert ! ( !found_a) ;
732
+ found_a = true ;
733
+ assert ! ( !chan. is_public) ;
734
+ }
735
+ }
736
+ assert ! ( found_a) ;
737
+
738
+ let mut found_b = false ;
739
+ for chan in nodes[ b] . node . list_usable_channels ( ) {
740
+ if chan. channel_id == as_funding_locked. channel_id {
741
+ assert ! ( !found_b) ;
742
+ found_b = true ;
743
+ assert ! ( !chan. is_public) ;
744
+ }
745
+ }
746
+ assert ! ( found_b) ;
747
+
748
+ ( as_funding_locked, tx)
749
+ }
750
+
696
751
pub fn update_nodes_with_chan_announce < ' a , ' b , ' c , ' d > ( nodes : & ' a Vec < Node < ' b , ' c , ' d > > , a : usize , b : usize , ann : & msgs:: ChannelAnnouncement , upd_1 : & msgs:: ChannelUpdate , upd_2 : & msgs:: ChannelUpdate ) {
697
752
nodes[ a] . node . broadcast_node_announcement ( [ 0 , 0 , 0 ] , [ 0 ; 32 ] , Vec :: new ( ) ) ;
698
753
let a_events = nodes[ a] . node . get_and_clear_pending_msg_events ( ) ;
@@ -748,6 +803,11 @@ pub fn update_nodes_with_chan_announce<'a, 'b, 'c, 'd>(nodes: &'a Vec<Node<'b, '
748
803
node. net_graph_msg_handler . handle_channel_update ( upd_2) . unwrap ( ) ;
749
804
node. net_graph_msg_handler . handle_node_announcement ( & a_node_announcement) . unwrap ( ) ;
750
805
node. net_graph_msg_handler . handle_node_announcement ( & b_node_announcement) . unwrap ( ) ;
806
+
807
+ // Note that channel_updates are also delivered to ChannelManagers to ensure we have
808
+ // forwarding info for local channels even if its not accepted in the network graph.
809
+ node. node . handle_channel_update ( & nodes[ a] . node . get_our_node_id ( ) , & upd_1) ;
810
+ node. node . handle_channel_update ( & nodes[ b] . node . get_our_node_id ( ) , & upd_2) ;
751
811
}
752
812
}
753
813
0 commit comments