@@ -25,17 +25,15 @@ fn test_v1_splice_in() {
2525 let initiator_node = & nodes[ initiator_node_index] ;
2626 let acceptor_node = & nodes[ acceptor_node_index] ;
2727
28- // Instantiate channel parameters where we push the maximum msats given our funding satoshis
29- let channel_value_sat = 100_000 ; // same as funding satoshis
30- let push_msat = 0 ;
28+ let channel_value_sat = 100_000 ;
3129 let channel_reserve_amnt_sat = 1_000 ;
3230
3331 let ( _, _, channel_id, _) = create_announced_chan_between_nodes_with_value (
3432 & nodes,
3533 initiator_node_index,
3634 acceptor_node_index,
3735 channel_value_sat,
38- push_msat,
36+ 0 , // push_msat,
3937 ) ;
4038
4139 let expected_funded_channel_id =
@@ -50,19 +48,18 @@ fn test_v1_splice_in() {
5048 // ==== Channel is now ready for normal operation
5149
5250 // === Start of Splicing
53- println ! ( "Start of Splicing ..., channel_id {}" , channel_id) ;
5451
5552 // Amount being added to the channel through the splice-in
56- let splice_in_sats: u64 = 20000 ;
57- let funding_feerate_per_kw = 1024 ; // TODO
53+ let splice_in_sats = 20_000 ;
54+ let funding_feerate_per_kw = 1024 ;
5855
5956 // Create additional inputs
6057 let extra_splice_funding_input_sats = 35_000 ;
6158 let funding_inputs = create_dual_funding_utxos_with_prev_txs (
6259 & initiator_node,
6360 & [ extra_splice_funding_input_sats] ,
6461 ) ;
65- // Initiate splice-in (on initiator_node)
62+ // Initiate splice-in
6663 let _res = initiator_node
6764 . node
6865 . splice_channel (
@@ -74,7 +71,7 @@ fn test_v1_splice_in() {
7471 None , // locktime
7572 )
7673 . unwrap ( ) ;
77- // Extract the splice message from node0 to node1
74+ // Extract the splice_init message
7875 let splice_init_msg = get_event_msg ! (
7976 initiator_node,
8077 MessageSendEvent :: SendSpliceInit ,
@@ -88,7 +85,7 @@ fn test_v1_splice_in() {
8885 let _res = acceptor_node
8986 . node
9087 . handle_splice_init ( initiator_node. node . get_our_node_id ( ) , & splice_init_msg) ;
91- // Extract the splice_ack message from node1 to node0
88+ // Extract the splice_ack message
9289 let splice_ack_msg = get_event_msg ! (
9390 acceptor_node,
9491 MessageSendEvent :: SendSpliceAck ,
@@ -157,3 +154,42 @@ fn test_v1_splice_in() {
157154 acceptor_node. node. get_our_node_id( )
158155 ) ;
159156}
157+
158+ #[ test]
159+ fn test_v1_splice_in_negative_insufficient_inputs ( ) {
160+ use crate :: util:: errors:: APIError ;
161+
162+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
163+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
164+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
165+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
166+
167+ let ( _, _, channel_id, _) =
168+ create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 100_000 , 0 ) ;
169+
170+ // Amount being added to the channel through the splice-in
171+ let splice_in_sats = 20_000 ;
172+
173+ // Create additional inputs, but insufficient
174+ let extra_splice_funding_input_sats = 19_900 ;
175+ assert ! ( extra_splice_funding_input_sats <= splice_in_sats) ;
176+ let funding_inputs =
177+ create_dual_funding_utxos_with_prev_txs ( & nodes[ 0 ] , & [ extra_splice_funding_input_sats] ) ;
178+
179+ // Initiate splice-in, with insufficient input contribution
180+ let res = nodes[ 0 ] . node . splice_channel (
181+ & channel_id,
182+ & nodes[ 1 ] . node . get_our_node_id ( ) ,
183+ splice_in_sats as i64 ,
184+ funding_inputs,
185+ 1024 , // funding_feerate_per_kw,
186+ None , // locktime
187+ ) ;
188+ assert ! ( res. is_err( ) ) ;
189+ match res {
190+ Err ( APIError :: APIMisuseError { err } ) => {
191+ assert ! ( err. contains( "Insufficient inputs for splicing" ) )
192+ } ,
193+ _ => panic ! ( "Wrong error {:?}" , res. err( ) . unwrap( ) ) ,
194+ }
195+ }
0 commit comments