@@ -1194,33 +1194,31 @@ fn test_trivial_inflight_htlc_tracking(){
11941194 let ( _, _, chan_2_id, _) = create_announced_chan_between_nodes ( & nodes, 1 , 2 ) ;
11951195
11961196 // 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 ( ) ;
12021199 {
1203- let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1204-
12051200 let mut node_0_per_peer_lock;
12061201 let mut node_0_peer_state_lock;
1207- let mut node_1_per_peer_lock;
1208- let mut node_1_peer_state_lock;
12091202 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) ;
12111203
12121204 let chan_1_used_liquidity = inflight_htlcs. used_liquidity_msat (
12131205 & NodeId :: from_pubkey ( & nodes[ 0 ] . node . get_our_node_id ( ) ) ,
12141206 & NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
12151207 channel_1. get_short_channel_id ( ) . unwrap ( )
12161208 ) ;
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+
12171216 let chan_2_used_liquidity = inflight_htlcs. used_liquidity_msat (
12181217 & NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
12191218 & NodeId :: from_pubkey ( & nodes[ 2 ] . node . get_our_node_id ( ) ) ,
12201219 channel_2. get_short_channel_id ( ) . unwrap ( )
12211220 ) ;
12221221
1223- assert_eq ! ( chan_1_used_liquidity, None ) ;
12241222 assert_eq ! ( chan_2_used_liquidity, None ) ;
12251223 }
12261224 let pending_payments = nodes[ 0 ] . node . list_recent_payments ( ) ;
@@ -1233,30 +1231,32 @@ fn test_trivial_inflight_htlc_tracking(){
12331231 }
12341232
12351233 // 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 ( ) ;
12371236 {
1238- let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1239-
12401237 let mut node_0_per_peer_lock;
12411238 let mut node_0_peer_state_lock;
1242- let mut node_1_per_peer_lock;
1243- let mut node_1_peer_state_lock;
12441239 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) ;
12461240
12471241 let chan_1_used_liquidity = inflight_htlcs. used_liquidity_msat (
12481242 & NodeId :: from_pubkey ( & nodes[ 0 ] . node . get_our_node_id ( ) ) ,
12491243 & NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
12501244 channel_1. get_short_channel_id ( ) . unwrap ( )
12511245 ) ;
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+
12521254 let chan_2_used_liquidity = inflight_htlcs. used_liquidity_msat (
12531255 & NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
12541256 & NodeId :: from_pubkey ( & nodes[ 2 ] . node . get_our_node_id ( ) ) ,
12551257 channel_2. get_short_channel_id ( ) . unwrap ( )
12561258 ) ;
12571259
1258- // First hop accounts for expected 1000 msat fee
1259- assert_eq ! ( chan_1_used_liquidity, Some ( 501000 ) ) ;
12601260 assert_eq ! ( chan_2_used_liquidity, Some ( 500000 ) ) ;
12611261 }
12621262 let pending_payments = nodes[ 0 ] . node . list_recent_payments ( ) ;
@@ -1271,28 +1271,29 @@ fn test_trivial_inflight_htlc_tracking(){
12711271 nodes[ 0 ] . node . timer_tick_occurred ( ) ;
12721272 }
12731273
1274+ let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
12741275 {
1275- let inflight_htlcs = node_chanmgrs[ 0 ] . compute_inflight_htlcs ( ) ;
1276-
12771276 let mut node_0_per_peer_lock;
12781277 let mut node_0_peer_state_lock;
1279- let mut node_1_per_peer_lock;
1280- let mut node_1_peer_state_lock;
12811278 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) ;
12831279
12841280 let chan_1_used_liquidity = inflight_htlcs. used_liquidity_msat (
12851281 & NodeId :: from_pubkey ( & nodes[ 0 ] . node . get_our_node_id ( ) ) ,
12861282 & NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
12871283 channel_1. get_short_channel_id ( ) . unwrap ( )
12881284 ) ;
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+
12891292 let chan_2_used_liquidity = inflight_htlcs. used_liquidity_msat (
12901293 & NodeId :: from_pubkey ( & nodes[ 1 ] . node . get_our_node_id ( ) ) ,
12911294 & NodeId :: from_pubkey ( & nodes[ 2 ] . node . get_our_node_id ( ) ) ,
12921295 channel_2. get_short_channel_id ( ) . unwrap ( )
12931296 ) ;
1294-
1295- assert_eq ! ( chan_1_used_liquidity, None ) ;
12961297 assert_eq ! ( chan_2_used_liquidity, None ) ;
12971298 }
12981299
0 commit comments