11use crate :: tests:: test_utils:: expect_event;
2- use crate :: { Builder , Config , Error , Event } ;
2+ use crate :: { Builder , Config , Error , Event , PaymentDirection , PaymentStatus } ;
33
44use bitcoin:: { Address , Amount , Txid } ;
55use bitcoind:: bitcoincore_rpc:: RpcApi ;
@@ -217,7 +217,7 @@ fn channel_full_cycle() {
217217
218218 let invoice = node_b. receive_payment ( invoice_amount, & "asdf" , 9217 ) . unwrap ( ) ;
219219 let overpaid_amount = invoice_amount + 100 ;
220- node_a. send_payment_using_amount ( invoice, overpaid_amount) . unwrap ( ) ;
220+ let payment_hash = node_a. send_payment_using_amount ( invoice, overpaid_amount) . unwrap ( ) ;
221221 expect_event ! ( node_a, PaymentSuccessful ) ;
222222 let received_amount = match node_b. next_event ( ) {
223223 ref e @ Event :: PaymentReceived { amount_msat, .. } => {
@@ -230,12 +230,19 @@ fn channel_full_cycle() {
230230 }
231231 } ;
232232 assert_eq ! ( received_amount, overpaid_amount) ;
233+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . status, PaymentStatus :: Succeeded ) ;
234+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . direction, PaymentDirection :: Outbound ) ;
235+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . amount_msat, Some ( overpaid_amount) ) ;
236+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . status, PaymentStatus :: Succeeded ) ;
237+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . direction, PaymentDirection :: Inbound ) ;
238+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . amount_msat, Some ( overpaid_amount) ) ;
233239
234240 // Test "zero-amount" invoice payment
235241 let variable_amount_invoice = node_b. receive_variable_amount_payment ( & "asdf" , 9217 ) . unwrap ( ) ;
236242 let determined_amount = 1234567 ;
237243 assert_eq ! ( Err ( Error :: InvalidInvoice ) , node_a. send_payment( variable_amount_invoice. clone( ) ) ) ;
238- node_a. send_payment_using_amount ( variable_amount_invoice, determined_amount) . unwrap ( ) ;
244+ let payment_hash =
245+ node_a. send_payment_using_amount ( variable_amount_invoice, determined_amount) . unwrap ( ) ;
239246
240247 expect_event ! ( node_a, PaymentSuccessful ) ;
241248 let received_amount = match node_b. next_event ( ) {
@@ -249,6 +256,12 @@ fn channel_full_cycle() {
249256 }
250257 } ;
251258 assert_eq ! ( received_amount, determined_amount) ;
259+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . status, PaymentStatus :: Succeeded ) ;
260+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . direction, PaymentDirection :: Outbound ) ;
261+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . amount_msat, Some ( determined_amount) ) ;
262+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . status, PaymentStatus :: Succeeded ) ;
263+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . direction, PaymentDirection :: Inbound ) ;
264+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . amount_msat, Some ( determined_amount) ) ;
252265
253266 node_b. close_channel ( & channel_id, & node_a. node_id ( ) ) . unwrap ( ) ;
254267 expect_event ! ( node_a, ChannelClosed ) ;
0 commit comments