@@ -17,7 +17,9 @@ use crate::events::bump_transaction::sync::WalletSourceSync;
1717use crate :: events:: { ClosureReason , Event , FundingInfo , HTLCHandlingFailureType } ;
1818use crate :: ln:: chan_utils;
1919use crate :: ln:: channel:: CHANNEL_ANNOUNCEMENT_PROPAGATION_DELAY ;
20- use crate :: ln:: channelmanager:: { PaymentId , RecipientOnionFields , BREAKDOWN_TIMEOUT } ;
20+ use crate :: ln:: channelmanager:: {
21+ provided_init_features, PaymentId , RecipientOnionFields , BREAKDOWN_TIMEOUT ,
22+ } ;
2123use crate :: ln:: functional_test_utils:: * ;
2224use crate :: ln:: funding:: { FundingTxInput , SpliceContribution } ;
2325use crate :: ln:: msgs:: { self , BaseMessageHandler , ChannelMessageHandler , MessageSendEvent } ;
@@ -30,6 +32,69 @@ use crate::util::test_channel_signer::SignerOp;
3032use bitcoin:: secp256k1:: PublicKey ;
3133use bitcoin:: { Amount , OutPoint as BitcoinOutPoint , ScriptBuf , Transaction , TxOut } ;
3234
35+ #[ test]
36+ fn test_splicing_not_supported_api_error ( ) {
37+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
38+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
39+ let mut features = provided_init_features ( & test_default_channel_config ( ) ) ;
40+ features. clear_splicing ( ) ;
41+ * node_cfgs[ 0 ] . override_init_features . borrow_mut ( ) = Some ( features) ;
42+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
43+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
44+
45+ let node_id_0 = nodes[ 0 ] . node . get_our_node_id ( ) ;
46+ let node_id_1 = nodes[ 1 ] . node . get_our_node_id ( ) ;
47+
48+ let ( _, _, channel_id, _) = create_announced_chan_between_nodes ( & nodes, 0 , 1 ) ;
49+
50+ let bs_contribution = SpliceContribution :: SpliceIn {
51+ value : Amount :: ZERO ,
52+ inputs : Vec :: new ( ) ,
53+ change_script : None ,
54+ } ;
55+
56+ let res = nodes[ 1 ] . node . splice_channel (
57+ & channel_id,
58+ & node_id_0,
59+ bs_contribution. clone ( ) ,
60+ 0 , // funding_feerate_per_kw,
61+ None , // locktime
62+ ) ;
63+ match res {
64+ Err ( APIError :: ChannelUnavailable { err } ) => {
65+ assert ! ( err. contains( "Peer does not support splicing" ) )
66+ } ,
67+ _ => panic ! ( "Wrong error {:?}" , res. err( ) . unwrap( ) ) ,
68+ }
69+
70+ nodes[ 0 ] . node . peer_disconnected ( node_id_1) ;
71+ nodes[ 1 ] . node . peer_disconnected ( node_id_0) ;
72+
73+ let mut features = nodes[ 0 ] . node . init_features ( ) ;
74+ features. set_splicing_optional ( ) ;
75+ features. clear_quiescence ( ) ;
76+ * nodes[ 0 ] . override_init_features . borrow_mut ( ) = Some ( features) ;
77+
78+ let mut reconnect_args = ReconnectArgs :: new ( & nodes[ 0 ] , & nodes[ 1 ] ) ;
79+ reconnect_args. send_channel_ready = ( true , true ) ;
80+ reconnect_args. send_announcement_sigs = ( true , true ) ;
81+ reconnect_nodes ( reconnect_args) ;
82+
83+ let res = nodes[ 1 ] . node . splice_channel (
84+ & channel_id,
85+ & node_id_0,
86+ bs_contribution,
87+ 0 , // funding_feerate_per_kw,
88+ None , // locktime
89+ ) ;
90+ match res {
91+ Err ( APIError :: ChannelUnavailable { err } ) => {
92+ assert ! ( err. contains( "Peer does not support quiescence, a splicing prerequisite" ) )
93+ } ,
94+ _ => panic ! ( "Wrong error {:?}" , res. err( ) . unwrap( ) ) ,
95+ }
96+ }
97+
3398#[ test]
3499fn test_v1_splice_in_negative_insufficient_inputs ( ) {
35100 let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
0 commit comments