@@ -18,7 +18,7 @@ use crate::ln::msgs;
1818use crate :: ln:: msgs:: ChannelMessageHandler ;
1919use crate :: ln:: channelmanager:: { PaymentId , RAACommitmentOrder , RecipientOnionFields } ;
2020use crate :: util:: ser:: Writeable ;
21- use crate :: util:: test_channel_signer:: ops;
21+ use crate :: util:: test_channel_signer:: { EnforcementState , ops} ;
2222use crate :: util:: test_utils;
2323
2424/// Helper to run operations with a simulated asynchronous signer.
@@ -49,6 +49,42 @@ pub fn with_async_signer<'a, DoFn, T>(node: &Node, peer_id: &PublicKey, channel_
4949 res
5050}
5151
52+ #[ test]
53+ fn test_open_channel ( ) {
54+ // Simulate acquiring the signature for `funding_created` asynchronously.
55+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
56+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
57+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
58+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
59+
60+ let channel_id_0 = EnforcementState :: with_default_unavailable (
61+ ops:: GET_PER_COMMITMENT_POINT ,
62+ || nodes[ 0 ] . node . create_channel ( nodes[ 1 ] . node . get_our_node_id ( ) , 100000 , 10001 , 42 , None , None )
63+ ) . expect ( "Failed to create channel" ) ;
64+
65+ {
66+ let msgs = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
67+ assert ! ( msgs. is_empty( ) , "Expected no message events; got {:?}" , msgs) ;
68+ }
69+
70+ nodes[ 0 ] . set_channel_signer_ops_available ( & nodes[ 1 ] . node . get_our_node_id ( ) , & channel_id_0, ops:: GET_PER_COMMITMENT_POINT , true ) ;
71+ nodes[ 0 ] . node . signer_unblocked ( None ) ;
72+
73+ // nodes[0] --- open_channel --> nodes[1]
74+ let mut open_chan_msg = get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendOpenChannel , nodes[ 1 ] . node. get_our_node_id( ) ) ;
75+
76+ EnforcementState :: with_default_unavailable (
77+ ops:: GET_PER_COMMITMENT_POINT ,
78+ || nodes[ 1 ] . node . handle_open_channel ( & nodes[ 0 ] . node . get_our_node_id ( ) , & open_chan_msg)
79+ ) ;
80+
81+ {
82+ let msgs = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
83+ assert ! ( msgs. is_empty( ) , "Expected no message events; got {:?}" , msgs) ;
84+ }
85+
86+ }
87+
5288#[ cfg( test) ]
5389fn do_test_funding_created ( masks : & Vec < u32 > ) {
5490 // Simulate acquiring the signature for `funding_created` asynchronously.
0 commit comments