@@ -53,7 +53,7 @@ fn test_v1_splice_in() {
5353 println ! ( "Start of Splicing ..., channel_id {}" , channel_id) ;
5454
5555 // Amount being added to the channel through the splice-in
56- let splice_in_sats: u64 = 20000 ;
56+ let splice_in_sats: u64 = 20_000 ;
5757 let funding_feerate_per_kw = 1024 ; // TODO
5858
5959 // Create additional inputs
@@ -157,3 +157,61 @@ fn test_v1_splice_in() {
157157 acceptor_node. node. get_our_node_id( )
158158 ) ;
159159}
160+
161+ #[ test]
162+ fn test_v1_splice_in_negative_inufficient_inputs ( ) {
163+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
164+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
165+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , None ] ) ;
166+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
167+
168+ // Initiator and Acceptor nodes
169+ let initiator_node_index = 0 ;
170+ let acceptor_node_index = 1 ;
171+ let initiator_node = & nodes[ initiator_node_index] ;
172+ let acceptor_node = & nodes[ acceptor_node_index] ;
173+
174+ // Instantiate channel parameters where we push the maximum msats given our funding satoshis
175+ let channel_value_sat = 100_000 ; // same as funding satoshis
176+ let push_msat = 0 ;
177+
178+ let ( _, _, channel_id, _) = create_announced_chan_between_nodes_with_value (
179+ & nodes,
180+ initiator_node_index,
181+ acceptor_node_index,
182+ channel_value_sat,
183+ push_msat,
184+ ) ;
185+
186+ // ==== Channel is now ready for normal operation
187+
188+ // === Start of Splicing
189+ println ! ( "Start of Splicing ..., channel_id {}" , channel_id) ;
190+
191+ // Amount being added to the channel through the splice-in
192+ let splice_in_sats: u64 = 20_000 ;
193+
194+ // Create additional inputs, but insufficient
195+ let extra_splice_funding_input_sats = 19_900 ;
196+ assert ! ( extra_splice_funding_input_sats <= splice_in_sats) ;
197+ let funding_inputs = create_dual_funding_utxos_with_prev_txs (
198+ & initiator_node,
199+ & [ extra_splice_funding_input_sats] ,
200+ ) ;
201+ // Initiate splice-in, with insufficient input contribution
202+ let res = initiator_node. node . splice_channel (
203+ & channel_id,
204+ & acceptor_node. node . get_our_node_id ( ) ,
205+ splice_in_sats as i64 ,
206+ funding_inputs,
207+ 1024 , // funding_feerate_per_kw,
208+ None , // locktime
209+ ) ;
210+ assert ! ( res. is_err( ) ) ;
211+ match res. as_ref ( ) . err ( ) . unwrap ( ) {
212+ crate :: util:: errors:: APIError :: APIMisuseError { err } => {
213+ assert ! ( err. contains( "nsufficient" ) )
214+ } ,
215+ _ => panic ! ( "Wrong error {:?}" , res. err( ) . unwrap( ) ) ,
216+ }
217+ }
0 commit comments