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 , OutPoint , Txid } ;
55use bitcoind:: bitcoincore_rpc:: RpcApi ;
@@ -239,7 +239,7 @@ fn channel_full_cycle() {
239239
240240 let invoice = node_b. receive_payment ( invoice_amount, & "asdf" , 9217 ) . unwrap ( ) ;
241241 let overpaid_amount = invoice_amount + 100 ;
242- node_a. send_payment_using_amount ( invoice, overpaid_amount) . unwrap ( ) ;
242+ let payment_hash = node_a. send_payment_using_amount ( invoice, overpaid_amount) . unwrap ( ) ;
243243 expect_event ! ( node_a, PaymentSuccessful ) ;
244244 let received_amount = match node_b. next_event ( ) {
245245 ref e @ Event :: PaymentReceived { amount_msat, .. } => {
@@ -252,12 +252,19 @@ fn channel_full_cycle() {
252252 }
253253 } ;
254254 assert_eq ! ( received_amount, overpaid_amount) ;
255+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . status, PaymentStatus :: Succeeded ) ;
256+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . direction, PaymentDirection :: Outbound ) ;
257+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . amount_msat, Some ( overpaid_amount) ) ;
258+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . status, PaymentStatus :: Succeeded ) ;
259+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . direction, PaymentDirection :: Inbound ) ;
260+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . amount_msat, Some ( overpaid_amount) ) ;
255261
256262 // Test "zero-amount" invoice payment
257263 let variable_amount_invoice = node_b. receive_variable_amount_payment ( & "asdf" , 9217 ) . unwrap ( ) ;
258264 let determined_amount = 1234567 ;
259265 assert_eq ! ( Err ( Error :: InvalidInvoice ) , node_a. send_payment( variable_amount_invoice. clone( ) ) ) ;
260- node_a. send_payment_using_amount ( variable_amount_invoice, determined_amount) . unwrap ( ) ;
266+ let payment_hash =
267+ node_a. send_payment_using_amount ( variable_amount_invoice, determined_amount) . unwrap ( ) ;
261268
262269 expect_event ! ( node_a, PaymentSuccessful ) ;
263270 let received_amount = match node_b. next_event ( ) {
@@ -271,6 +278,12 @@ fn channel_full_cycle() {
271278 }
272279 } ;
273280 assert_eq ! ( received_amount, determined_amount) ;
281+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . status, PaymentStatus :: Succeeded ) ;
282+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . direction, PaymentDirection :: Outbound ) ;
283+ assert_eq ! ( node_a. payment_info( & payment_hash) . unwrap( ) . amount_msat, Some ( determined_amount) ) ;
284+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . status, PaymentStatus :: Succeeded ) ;
285+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . direction, PaymentDirection :: Inbound ) ;
286+ assert_eq ! ( node_b. payment_info( & payment_hash) . unwrap( ) . amount_msat, Some ( determined_amount) ) ;
274287
275288 node_b. close_channel ( & channel_id, & node_a. node_id ( ) ) . unwrap ( ) ;
276289 expect_event ! ( node_a, ChannelClosed ) ;
0 commit comments