@@ -28,6 +28,7 @@ fn test_v1_splice_in() {
2828
2929	let  channel_value_sat = 100_000 ; 
3030	let  channel_reserve_amnt_sat = 1_000 ; 
31+ 	let  expect_outputs_in_reverse = true ; 
3132
3233	let  ( _,  _,  channel_id,  _)  = create_announced_chan_between_nodes_with_value ( 
3334		& nodes, 
@@ -142,17 +143,24 @@ fn test_v1_splice_in() {
142143		acceptor_node. node. get_our_node_id( ) 
143144	) ; 
144145	dbg ! ( & tx_add_input_msg) ; 
145- 	// check which input is this 
146- 	let  inputs_seen_in_reverse = if  let  Some ( prevtx)  = tx_add_input_msg. prevtx . as_ref ( )  { 
147- 		let  value = prevtx
148- 			. as_transaction ( ) 
149- 			. output [ tx_add_input_msg. prevtx_out  as  usize ] 
146+ 	// check which input is this (order is non-deterministic), based on the presense of prevtx 
147+ 	let  inputs_seen_in_reverse = tx_add_input_msg. prevtx . is_some ( ) ; 
148+ 	if  !inputs_seen_in_reverse { 
149+ 		// Input is the revious funding input 
150+ 		assert_eq ! ( tx_add_input_msg. prevtx,  None ) ; 
151+ 		assert_eq ! ( 
152+ 			tx_add_input_msg. shared_input_txid. unwrap( ) . to_string( ) , 
153+ 			"4f128bedf1a15baf465ab1bfd6e97c8f82628f4156bf86eb1cbc132cda6733ae" 
154+ 		) ; 
155+ 	}  else  { 
156+ 		// Input is the extra input 
157+ 		let  prevtx_value = tx_add_input_msg. prevtx . as_ref ( ) . unwrap ( ) . as_transaction ( ) . output 
158+ 			[ tx_add_input_msg. prevtx_out  as  usize ] 
150159			. value 
151160			. to_sat ( ) ; 
152- 		value == extra_splice_funding_input_sats
153- 	}  else  { 
154- 		false 
155- 	} ; 
161+ 		assert_eq ! ( prevtx_value,  extra_splice_funding_input_sats) ; 
162+ 		assert_eq ! ( tx_add_input_msg. shared_input_txid,  None ) ; 
163+ 	} 
156164
157165	let  _res = acceptor_node
158166		. node 
@@ -167,17 +175,28 @@ fn test_v1_splice_in() {
167175		. node 
168176		. handle_tx_complete ( acceptor_node. node . get_our_node_id ( ) ,  & tx_complete_msg) ; 
169177	// Second input 
170- 	let  exp_value =
171- 		if  inputs_seen_in_reverse {  channel_value_sat }  else  {  extra_splice_funding_input_sats } ; 
172178	let  tx_add_input2_msg = get_event_msg ! ( 
173179		& initiator_node, 
174180		MessageSendEvent :: SendTxAddInput , 
175181		acceptor_node. node. get_our_node_id( ) 
176182	) ; 
177183	dbg ! ( & tx_add_input2_msg) ; 
178- 	// FIXME: Determine why these fail 
179- 	//assert_eq!(tx_add_input2_msg.prevtx, None); 
180- 	//assert_eq!(tx_add_input2_msg.shared_input_txid.unwrap().to_string(), "4f128bedf1a15baf465ab1bfd6e97c8f82628f4156bf86eb1cbc132cda6733ae"); 
184+ 	if  !inputs_seen_in_reverse { 
185+ 		// Input is the extra input 
186+ 		let  prevtx_value = tx_add_input2_msg. prevtx . as_ref ( ) . unwrap ( ) . as_transaction ( ) . output 
187+ 			[ tx_add_input2_msg. prevtx_out  as  usize ] 
188+ 			. value 
189+ 			. to_sat ( ) ; 
190+ 		assert_eq ! ( prevtx_value,  extra_splice_funding_input_sats) ; 
191+ 		assert_eq ! ( tx_add_input2_msg. shared_input_txid,  None ) ; 
192+ 	}  else  { 
193+ 		// Input is the revious funding input 
194+ 		assert_eq ! ( tx_add_input2_msg. prevtx,  None ) ; 
195+ 		assert_eq ! ( 
196+ 			tx_add_input2_msg. shared_input_txid. unwrap( ) . to_string( ) , 
197+ 			"4f128bedf1a15baf465ab1bfd6e97c8f82628f4156bf86eb1cbc132cda6733ae" 
198+ 		) ; 
199+ 	} 
181200
182201	let  _res = acceptor_node
183202		. node 
@@ -199,9 +218,13 @@ fn test_v1_splice_in() {
199218		acceptor_node. node. get_our_node_id( ) 
200219	) ; 
201220	dbg ! ( & tx_add_output_msg) ; 
202- 	// FIXME: Determine why these fail 
203- 	//assert!(tx_add_output_msg.script.is_p2wsh()); 
204- 	//assert_eq!(tx_add_output_msg.sats, post_splice_channel_value); 
221+ 	if  !expect_outputs_in_reverse { 
222+ 		assert ! ( tx_add_output_msg. script. is_p2wsh( ) ) ; 
223+ 		assert_eq ! ( tx_add_output_msg. sats,  post_splice_channel_value) ; 
224+ 	}  else  { 
225+ 		assert ! ( tx_add_output_msg. script. is_p2wpkh( ) ) ; 
226+ 		assert_eq ! ( tx_add_output_msg. sats,  14146 ) ;  // extra_splice_funding_input_sats - splice_in_sats 
227+ 	} 
205228
206229	let  _res = acceptor_node
207230		. node 
@@ -222,9 +245,13 @@ fn test_v1_splice_in() {
222245		acceptor_node. node. get_our_node_id( ) 
223246	) ; 
224247	dbg ! ( & tx_add_output2_msg) ; 
225- 	// FIXME: Determine why these fail 
226- 	//assert!(tx_add_output2_msg.script.is_p2wpkh()); 
227- 	//assert_eq!(tx_add_output2_msg.sats, 14094); // extra_splice_input_sats - splice_in_sats 
248+ 	if  !expect_outputs_in_reverse { 
249+ 		assert ! ( tx_add_output2_msg. script. is_p2wpkh( ) ) ; 
250+ 		assert_eq ! ( tx_add_output2_msg. sats,  14146 ) ;  // extra_splice_funding_input_sats - splice_in_sats 
251+ 	}  else  { 
252+ 		assert ! ( tx_add_output2_msg. script. is_p2wsh( ) ) ; 
253+ 		assert_eq ! ( tx_add_output2_msg. sats,  post_splice_channel_value) ; 
254+ 	} 
228255
229256	let  _res = acceptor_node
230257		. node 
0 commit comments