1
1
use crate :: tests:: test_utils:: expect_event;
2
- use crate :: { Builder , Config , Error , Event } ;
2
+ use crate :: { Builder , Config , Error , Event , PaymentDirection , PaymentStatus } ;
3
3
4
4
use bitcoin:: { Address , Amount , OutPoint , Txid } ;
5
5
use bitcoind:: bitcoincore_rpc:: RpcApi ;
@@ -239,7 +239,7 @@ fn channel_full_cycle() {
239
239
240
240
let invoice = node_b. receive_payment ( invoice_amount, & "asdf" , 9217 ) . unwrap ( ) ;
241
241
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 ( ) ;
243
243
expect_event ! ( node_a, PaymentSuccessful ) ;
244
244
let received_amount = match node_b. next_event ( ) {
245
245
ref e @ Event :: PaymentReceived { amount_msat, .. } => {
@@ -252,12 +252,19 @@ fn channel_full_cycle() {
252
252
}
253
253
} ;
254
254
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) ) ;
255
261
256
262
// Test "zero-amount" invoice payment
257
263
let variable_amount_invoice = node_b. receive_variable_amount_payment ( & "asdf" , 9217 ) . unwrap ( ) ;
258
264
let determined_amount = 1234567 ;
259
265
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 ( ) ;
261
268
262
269
expect_event ! ( node_a, PaymentSuccessful ) ;
263
270
let received_amount = match node_b. next_event ( ) {
@@ -271,6 +278,12 @@ fn channel_full_cycle() {
271
278
}
272
279
} ;
273
280
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) ) ;
274
287
275
288
node_b. close_channel ( & channel_id, & node_a. node_id ( ) ) . unwrap ( ) ;
276
289
expect_event ! ( node_a, ChannelClosed ) ;
0 commit comments