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 , Txid } ;
5
5
use bitcoind:: bitcoincore_rpc:: RpcApi ;
@@ -217,7 +217,7 @@ fn channel_full_cycle() {
217
217
218
218
let invoice = node_b. receive_payment ( invoice_amount, & "asdf" , 9217 ) . unwrap ( ) ;
219
219
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 ( ) ;
221
221
expect_event ! ( node_a, PaymentSuccessful ) ;
222
222
let received_amount = match node_b. next_event ( ) {
223
223
ref e @ Event :: PaymentReceived { amount_msat, .. } => {
@@ -230,12 +230,19 @@ fn channel_full_cycle() {
230
230
}
231
231
} ;
232
232
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) ) ;
233
239
234
240
// Test "zero-amount" invoice payment
235
241
let variable_amount_invoice = node_b. receive_variable_amount_payment ( & "asdf" , 9217 ) . unwrap ( ) ;
236
242
let determined_amount = 1234567 ;
237
243
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 ( ) ;
239
246
240
247
expect_event ! ( node_a, PaymentSuccessful ) ;
241
248
let received_amount = match node_b. next_event ( ) {
@@ -249,6 +256,12 @@ fn channel_full_cycle() {
249
256
}
250
257
} ;
251
258
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) ) ;
252
265
253
266
node_b. close_channel ( & channel_id, & node_a. node_id ( ) ) . unwrap ( ) ;
254
267
expect_event ! ( node_a, ChannelClosed ) ;
0 commit comments