@@ -1194,33 +1194,31 @@ fn test_trivial_inflight_htlc_tracking(){
1194
1194
let ( _, _, chan_2_id, _) = create_announced_chan_between_nodes ( & nodes, 1 , 2 ) ;
1195
1195
1196
1196
// Send and claim the payment. Inflight HTLCs should be empty.
1197
- let ( route, payment_hash, payment_preimage, payment_secret) = get_route_and_payment_hash ! ( nodes[ 0 ] , nodes[ 2 ] , 500000 ) ;
1198
- nodes[ 0 ] . node . send_payment ( & route, payment_hash, & Some ( payment_secret) , PaymentId ( payment_hash. 0 ) ) . unwrap ( ) ;
1199
- check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
1200
- pass_along_route ( & nodes[ 0 ] , & [ & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] ] , 500000 , payment_hash, payment_secret) ;
1201
- claim_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] , payment_preimage) ;
1197
+ let payment_hash = send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 500000 ) . 1 ;
1198
+ let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1202
1199
{
1203
- let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1204
-
1205
1200
let mut node_0_per_peer_lock;
1206
1201
let mut node_0_peer_state_lock;
1207
- let mut node_1_per_peer_lock;
1208
- let mut node_1_peer_state_lock;
1209
1202
let channel_1 = get_channel_ref ! ( & nodes[ 0 ] , nodes[ 1 ] , node_0_per_peer_lock, node_0_peer_state_lock, chan_1_id) ;
1210
- let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1211
1203
1212
1204
let chan_1_used_liquidity = inflight_htlcs. used_liquidity_msat (
1213
1205
& NodeId :: from_pubkey ( & nodes[ 0 ] . node . get_our_node_id ( ) ) ,
1214
1206
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1215
1207
channel_1. get_short_channel_id ( ) . unwrap ( )
1216
1208
) ;
1209
+ assert_eq ! ( chan_1_used_liquidity, None ) ;
1210
+ }
1211
+ {
1212
+ let mut node_1_per_peer_lock;
1213
+ let mut node_1_peer_state_lock;
1214
+ let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1215
+
1217
1216
let chan_2_used_liquidity = inflight_htlcs. used_liquidity_msat (
1218
1217
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1219
1218
& NodeId :: from_pubkey ( & nodes[ 2 ] . node . get_our_node_id ( ) ) ,
1220
1219
channel_2. get_short_channel_id ( ) . unwrap ( )
1221
1220
) ;
1222
1221
1223
- assert_eq ! ( chan_1_used_liquidity, None ) ;
1224
1222
assert_eq ! ( chan_2_used_liquidity, None ) ;
1225
1223
}
1226
1224
let pending_payments = nodes[ 0 ] . node . list_recent_payments ( ) ;
@@ -1233,30 +1231,32 @@ fn test_trivial_inflight_htlc_tracking(){
1233
1231
}
1234
1232
1235
1233
// Send the payment, but do not claim it. Our inflight HTLCs should contain the pending payment.
1236
- let ( payment_preimage, payment_hash, _) = route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] , & nodes[ 2 ] ) [ ..] , 500000 ) ;
1234
+ let ( payment_preimage, payment_hash, _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 500000 ) ;
1235
+ let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1237
1236
{
1238
- let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1239
-
1240
1237
let mut node_0_per_peer_lock;
1241
1238
let mut node_0_peer_state_lock;
1242
- let mut node_1_per_peer_lock;
1243
- let mut node_1_peer_state_lock;
1244
1239
let channel_1 = get_channel_ref ! ( & nodes[ 0 ] , nodes[ 1 ] , node_0_per_peer_lock, node_0_peer_state_lock, chan_1_id) ;
1245
- let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1246
1240
1247
1241
let chan_1_used_liquidity = inflight_htlcs. used_liquidity_msat (
1248
1242
& NodeId :: from_pubkey ( & nodes[ 0 ] . node . get_our_node_id ( ) ) ,
1249
1243
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1250
1244
channel_1. get_short_channel_id ( ) . unwrap ( )
1251
1245
) ;
1246
+ // First hop accounts for expected 1000 msat fee
1247
+ assert_eq ! ( chan_1_used_liquidity, Some ( 501000 ) ) ;
1248
+ }
1249
+ {
1250
+ let mut node_1_per_peer_lock;
1251
+ let mut node_1_peer_state_lock;
1252
+ let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1253
+
1252
1254
let chan_2_used_liquidity = inflight_htlcs. used_liquidity_msat (
1253
1255
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1254
1256
& NodeId :: from_pubkey ( & nodes[ 2 ] . node . get_our_node_id ( ) ) ,
1255
1257
channel_2. get_short_channel_id ( ) . unwrap ( )
1256
1258
) ;
1257
1259
1258
- // First hop accounts for expected 1000 msat fee
1259
- assert_eq ! ( chan_1_used_liquidity, Some ( 501000 ) ) ;
1260
1260
assert_eq ! ( chan_2_used_liquidity, Some ( 500000 ) ) ;
1261
1261
}
1262
1262
let pending_payments = nodes[ 0 ] . node . list_recent_payments ( ) ;
@@ -1271,28 +1271,29 @@ fn test_trivial_inflight_htlc_tracking(){
1271
1271
nodes[ 0 ] . node . timer_tick_occurred ( ) ;
1272
1272
}
1273
1273
1274
+ let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1274
1275
{
1275
- let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1276
-
1277
1276
let mut node_0_per_peer_lock;
1278
1277
let mut node_0_peer_state_lock;
1279
- let mut node_1_per_peer_lock;
1280
- let mut node_1_peer_state_lock;
1281
1278
let channel_1 = get_channel_ref ! ( & nodes[ 0 ] , nodes[ 1 ] , node_0_per_peer_lock, node_0_peer_state_lock, chan_1_id) ;
1282
- let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1283
1279
1284
1280
let chan_1_used_liquidity = inflight_htlcs. used_liquidity_msat (
1285
1281
& NodeId :: from_pubkey ( & nodes[ 0 ] . node . get_our_node_id ( ) ) ,
1286
1282
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1287
1283
channel_1. get_short_channel_id ( ) . unwrap ( )
1288
1284
) ;
1285
+ assert_eq ! ( chan_1_used_liquidity, None ) ;
1286
+ }
1287
+ {
1288
+ let mut node_1_per_peer_lock;
1289
+ let mut node_1_peer_state_lock;
1290
+ let channel_2 = get_channel_ref ! ( & nodes[ 1 ] , nodes[ 2 ] , node_1_per_peer_lock, node_1_peer_state_lock, chan_2_id) ;
1291
+
1289
1292
let chan_2_used_liquidity = inflight_htlcs. used_liquidity_msat (
1290
1293
& NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
1291
1294
& NodeId :: from_pubkey ( & nodes[ 2 ] . node . get_our_node_id ( ) ) ,
1292
1295
channel_2. get_short_channel_id ( ) . unwrap ( )
1293
1296
) ;
1294
-
1295
- assert_eq ! ( chan_1_used_liquidity, None ) ;
1296
1297
assert_eq ! ( chan_2_used_liquidity, None ) ;
1297
1298
}
1298
1299
0 commit comments