@@ -1275,83 +1275,88 @@ fn test_trivial_inflight_htlc_tracking(){
1275
1275
1276
1276
// Send and claim the payment. Inflight HTLCs should be empty.
1277
1277
send_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] , 500000 ) ;
1278
+ let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1278
1279
{
1279
- let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1280
-
1281
1280
let mut node_0_per_peer_lock;
1282
1281
let mut node_0_peer_state_lock;
1283
- let mut node_1_per_peer_lock;
1284
- let mut node_1_peer_state_lock;
1285
1282
let channel_1 = get_channel_ref ! ( & nodes[ 0 ] , nodes[ 1 ] , node_0_per_peer_lock, node_0_peer_state_lock, chan_1_id) ;
1286
- let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1287
1283
1288
1284
let chan_1_used_liquidity = inflight_htlcs. used_liquidity_msat (
1289
1285
& NodeId :: from_pubkey ( & nodes[ 0 ] . node . get_our_node_id ( ) ) ,
1290
1286
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1291
1287
channel_1. get_short_channel_id ( ) . unwrap ( )
1292
1288
) ;
1289
+ assert_eq ! ( chan_1_used_liquidity, None ) ;
1290
+ }
1291
+ {
1292
+ let mut node_1_per_peer_lock;
1293
+ let mut node_1_peer_state_lock;
1294
+ let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1295
+
1293
1296
let chan_2_used_liquidity = inflight_htlcs. used_liquidity_msat (
1294
1297
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1295
1298
& NodeId :: from_pubkey ( & nodes[ 2 ] . node . get_our_node_id ( ) ) ,
1296
1299
channel_2. get_short_channel_id ( ) . unwrap ( )
1297
1300
) ;
1298
1301
1299
- assert_eq ! ( chan_1_used_liquidity, None ) ;
1300
1302
assert_eq ! ( chan_2_used_liquidity, None ) ;
1301
1303
}
1302
1304
1303
1305
// Send the payment, but do not claim it. Our inflight HTLCs should contain the pending payment.
1304
1306
let ( payment_preimage, _, _) = route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] , 500000 ) ;
1307
+ let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1305
1308
{
1306
- let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1307
-
1308
1309
let mut node_0_per_peer_lock;
1309
1310
let mut node_0_peer_state_lock;
1310
- let mut node_1_per_peer_lock;
1311
- let mut node_1_peer_state_lock;
1312
1311
let channel_1 = get_channel_ref ! ( & nodes[ 0 ] , nodes[ 1 ] , node_0_per_peer_lock, node_0_peer_state_lock, chan_1_id) ;
1313
- let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1314
1312
1315
1313
let chan_1_used_liquidity = inflight_htlcs. used_liquidity_msat (
1316
1314
& NodeId :: from_pubkey ( & nodes[ 0 ] . node . get_our_node_id ( ) ) ,
1317
1315
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1318
1316
channel_1. get_short_channel_id ( ) . unwrap ( )
1319
1317
) ;
1318
+ // First hop accounts for expected 1000 msat fee
1319
+ assert_eq ! ( chan_1_used_liquidity, Some ( 501000 ) ) ;
1320
+ }
1321
+ {
1322
+ let mut node_1_per_peer_lock;
1323
+ let mut node_1_peer_state_lock;
1324
+ let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1325
+
1320
1326
let chan_2_used_liquidity = inflight_htlcs. used_liquidity_msat (
1321
1327
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1322
1328
& NodeId :: from_pubkey ( & nodes[ 2 ] . node . get_our_node_id ( ) ) ,
1323
1329
channel_2. get_short_channel_id ( ) . unwrap ( )
1324
1330
) ;
1325
1331
1326
- // First hop accounts for expected 1000 msat fee
1327
- assert_eq ! ( chan_1_used_liquidity, Some ( 501000 ) ) ;
1328
1332
assert_eq ! ( chan_2_used_liquidity, Some ( 500000 ) ) ;
1329
1333
}
1330
1334
1331
1335
// Now, let's claim the payment. This should result in the used liquidity to return `None`.
1332
1336
claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , payment_preimage) ;
1337
+ let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1333
1338
{
1334
- let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1335
-
1336
1339
let mut node_0_per_peer_lock;
1337
1340
let mut node_0_peer_state_lock;
1338
- let mut node_1_per_peer_lock;
1339
- let mut node_1_peer_state_lock;
1340
1341
let channel_1 = get_channel_ref ! ( & nodes[ 0 ] , nodes[ 1 ] , node_0_per_peer_lock, node_0_peer_state_lock, chan_1_id) ;
1341
- let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1342
1342
1343
1343
let chan_1_used_liquidity = inflight_htlcs. used_liquidity_msat (
1344
1344
& NodeId :: from_pubkey ( & nodes[ 0 ] . node . get_our_node_id ( ) ) ,
1345
1345
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1346
1346
channel_1. get_short_channel_id ( ) . unwrap ( )
1347
1347
) ;
1348
+ assert_eq ! ( chan_1_used_liquidity, None ) ;
1349
+ }
1350
+ {
1351
+ let mut node_1_per_peer_lock;
1352
+ let mut node_1_peer_state_lock;
1353
+ let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1354
+
1348
1355
let chan_2_used_liquidity = inflight_htlcs. used_liquidity_msat (
1349
1356
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1350
1357
& NodeId :: from_pubkey ( & nodes[ 2 ] . node . get_our_node_id ( ) ) ,
1351
1358
channel_2. get_short_channel_id ( ) . unwrap ( )
1352
1359
) ;
1353
-
1354
- assert_eq ! ( chan_1_used_liquidity, None ) ;
1355
1360
assert_eq ! ( chan_2_used_liquidity, None ) ;
1356
1361
}
1357
1362
}
0 commit comments