@@ -16,7 +16,7 @@ use crate::chain::channelmonitor::{ANTI_REORG_DELAY, LATENCY_GRACE_PERIOD_BLOCKS
16
16
use crate :: chain:: keysinterface:: EntropySource ;
17
17
use crate :: chain:: transaction:: OutPoint ;
18
18
use crate :: ln:: channel:: EXPIRE_PREV_CONFIG_TICKS ;
19
- use crate :: ln:: channelmanager:: { BREAKDOWN_TIMEOUT , ChannelManager , MPP_TIMEOUT_TICKS , MIN_CLTV_EXPIRY_DELTA , PaymentId , PaymentSendFailure , IDEMPOTENCY_TIMEOUT_TICKS } ;
19
+ use crate :: ln:: channelmanager:: { BREAKDOWN_TIMEOUT , ChannelManager , MPP_TIMEOUT_TICKS , MIN_CLTV_EXPIRY_DELTA , PaymentId , PaymentSendFailure , IDEMPOTENCY_TIMEOUT_TICKS , RecentPaymentDetails } ;
20
20
use crate :: ln:: msgs;
21
21
use crate :: ln:: msgs:: ChannelMessageHandler ;
22
22
use crate :: routing:: gossip:: RoutingFees ;
@@ -1267,7 +1267,11 @@ fn test_trivial_inflight_htlc_tracking(){
1267
1267
let ( _, _, chan_2_id, _) = create_announced_chan_between_nodes ( & nodes, 1 , 2 ) ;
1268
1268
1269
1269
// Send and claim the payment. Inflight HTLCs should be empty.
1270
- send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] , 500000 ) ;
1270
+ let ( route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash ! ( nodes[ 0 ] , nodes[ 2 ] , 500000 ) ;
1271
+ nodes[ 0 ] . node . send_payment ( & route, payment_hash, & Some ( payment_secret) , PaymentId ( payment_hash. 0 ) ) . unwrap ( ) ;
1272
+ check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
1273
+ pass_along_route ( & nodes[ 0 ] , & [ & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] ] , 500000 , payment_hash, payment_secret) ;
1274
+ claim_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] , payment_preimage) ;
1271
1275
{
1272
1276
let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1273
1277
@@ -1291,10 +1295,19 @@ fn test_trivial_inflight_htlc_tracking(){
1291
1295
1292
1296
assert_eq ! ( chan_1_used_liquidity, None ) ;
1293
1297
assert_eq ! ( chan_2_used_liquidity, None ) ;
1298
+
1299
+ let pending_payments = nodes[ 0 ] . node . list_recent_payments ( ) ;
1300
+ assert_eq ! ( pending_payments. len( ) , 1 ) ;
1301
+ assert_eq ! ( pending_payments[ 0 ] , RecentPaymentDetails :: Fulfilled { payment_hash: Some ( payment_hash) } ) ;
1302
+ }
1303
+
1304
+ // Remove fulfilled payment
1305
+ for _ in 0 ..=IDEMPOTENCY_TIMEOUT_TICKS {
1306
+ nodes[ 0 ] . node . timer_tick_occurred ( ) ;
1294
1307
}
1295
1308
1296
1309
// Send the payment, but do not claim it. Our inflight HTLCs should contain the pending payment.
1297
- let ( payment_preimage, _ , _) = route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] , 500000 ) ;
1310
+ let ( payment_preimage, payment_hash , _) = route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] , 500000 ) ;
1298
1311
{
1299
1312
let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1300
1313
@@ -1319,10 +1332,20 @@ fn test_trivial_inflight_htlc_tracking(){
1319
1332
// First hop accounts for expected 1000 msat fee
1320
1333
assert_eq ! ( chan_1_used_liquidity, Some ( 501000 ) ) ;
1321
1334
assert_eq ! ( chan_2_used_liquidity, Some ( 500000 ) ) ;
1335
+
1336
+ let pending_payments = nodes[ 0 ] . node . list_recent_payments ( ) ;
1337
+ assert_eq ! ( pending_payments. len( ) , 1 ) ;
1338
+ assert_eq ! ( pending_payments[ 0 ] , RecentPaymentDetails :: Pending { payment_hash, total_msat: 500000 } ) ;
1322
1339
}
1323
1340
1324
1341
// Now, let's claim the payment. This should result in the used liquidity to return `None`.
1325
1342
claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , payment_preimage) ;
1343
+
1344
+ // Remove fulfilled payment
1345
+ for _ in 0 ..=IDEMPOTENCY_TIMEOUT_TICKS {
1346
+ nodes[ 0 ] . node . timer_tick_occurred ( ) ;
1347
+ }
1348
+
1326
1349
{
1327
1350
let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1328
1351
@@ -1346,6 +1369,9 @@ fn test_trivial_inflight_htlc_tracking(){
1346
1369
1347
1370
assert_eq ! ( chan_1_used_liquidity, None ) ;
1348
1371
assert_eq ! ( chan_2_used_liquidity, None ) ;
1372
+
1373
+ let pending_payments = nodes[ 0 ] . node . list_recent_payments ( ) ;
1374
+ assert_eq ! ( pending_payments. len( ) , 0 ) ;
1349
1375
}
1350
1376
}
1351
1377
0 commit comments