@@ -4038,7 +4038,8 @@ fn do_test_htlc_timeout(send_partial_mpp: bool) {
4038
4038
} ;
4039
4039
connect_block ( & nodes[ 0 ] , & block) ;
4040
4040
connect_block ( & nodes[ 1 ] , & block) ;
4041
- for _ in CHAN_CONFIRM_DEPTH + 2 ..TEST_FINAL_CLTV + CHAN_CONFIRM_DEPTH + 2 - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS {
4041
+ let block_count = TEST_FINAL_CLTV + CHAN_CONFIRM_DEPTH + 2 - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS ;
4042
+ for _ in CHAN_CONFIRM_DEPTH + 2 ..block_count {
4042
4043
block. header . prev_blockhash = block. block_hash ( ) ;
4043
4044
connect_block ( & nodes[ 0 ] , & block) ;
4044
4045
connect_block ( & nodes[ 1 ] , & block) ;
@@ -4055,9 +4056,9 @@ fn do_test_htlc_timeout(send_partial_mpp: bool) {
4055
4056
4056
4057
nodes[ 0 ] . node . handle_update_fail_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & htlc_timeout_updates. update_fail_htlcs [ 0 ] ) ;
4057
4058
commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , htlc_timeout_updates. commitment_signed, false ) ;
4058
- // 100_000 msat as u64, followed by a height of TEST_FINAL_CLTV + 2 as u32
4059
+ // 100_000 msat as u64, followed by the height at which we failed back above
4059
4060
let mut expected_failure_data = byte_utils:: be64_to_array ( 100_000 ) . to_vec ( ) ;
4060
- expected_failure_data. extend_from_slice ( & byte_utils:: be32_to_array ( TEST_FINAL_CLTV + 2 ) ) ;
4061
+ expected_failure_data. extend_from_slice ( & byte_utils:: be32_to_array ( block_count - 1 ) ) ;
4061
4062
expect_payment_failed ! ( nodes[ 0 ] , our_payment_hash, true , 0x4000 | 15 , & expected_failure_data[ ..] ) ;
4062
4063
}
4063
4064
@@ -5182,7 +5183,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
5182
5183
let htlc_updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
5183
5184
assert ! ( htlc_updates. update_add_htlcs. is_empty( ) ) ;
5184
5185
assert_eq ! ( htlc_updates. update_fail_htlcs. len( ) , 1 ) ;
5185
- assert_eq ! ( htlc_updates. update_fail_htlcs[ 0 ] . htlc_id, 1 ) ;
5186
+ let first_htlc_id = htlc_updates. update_fail_htlcs [ 0 ] . htlc_id ;
5186
5187
assert ! ( htlc_updates. update_fulfill_htlcs. is_empty( ) ) ;
5187
5188
assert ! ( htlc_updates. update_fail_malformed_htlcs. is_empty( ) ) ;
5188
5189
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
@@ -5207,7 +5208,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
5207
5208
assert ! ( updates. update_add_htlcs. is_empty( ) ) ;
5208
5209
assert ! ( updates. update_fail_htlcs. is_empty( ) ) ;
5209
5210
assert_eq ! ( updates. update_fulfill_htlcs. len( ) , 1 ) ;
5210
- assert_eq ! ( updates. update_fulfill_htlcs[ 0 ] . htlc_id, 0 ) ;
5211
+ assert_ne ! ( updates. update_fulfill_htlcs[ 0 ] . htlc_id, first_htlc_id ) ;
5211
5212
assert ! ( updates. update_fail_malformed_htlcs. is_empty( ) ) ;
5212
5213
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
5213
5214
@@ -7743,9 +7744,13 @@ fn test_bump_penalty_txn_on_revoked_htlcs() {
7743
7744
let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
7744
7745
7745
7746
let chan = create_announced_chan_between_nodes_with_value ( & nodes, 0 , 1 , 1000000 , 59000000 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) ;
7746
- // Lock HTLC in both directions
7747
- let payment_preimage = route_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , 3_000_000 ) . 0 ;
7748
- route_payment ( & nodes[ 1 ] , & vec ! ( & nodes[ 0 ] ) [ ..] , 3_000_000 ) . 0 ;
7747
+ // Lock HTLC in both directions (using a slightly lower CLTV delay to provide timely RBF bumps)
7748
+ let route = get_route ( & nodes[ 0 ] . node . get_our_node_id ( ) , & nodes[ 0 ] . net_graph_msg_handler . network_graph . read ( ) . unwrap ( ) ,
7749
+ & nodes[ 1 ] . node . get_our_node_id ( ) , Some ( InvoiceFeatures :: known ( ) ) , None , & Vec :: new ( ) , 3_000_000 , 50 , nodes[ 0 ] . logger ) . unwrap ( ) ;
7750
+ let payment_preimage = send_along_route ( & nodes[ 0 ] , route, & [ & nodes[ 1 ] ] , 3_000_000 ) . 0 ;
7751
+ let route = get_route ( & nodes[ 1 ] . node . get_our_node_id ( ) , & nodes[ 1 ] . net_graph_msg_handler . network_graph . read ( ) . unwrap ( ) ,
7752
+ & nodes[ 0 ] . node . get_our_node_id ( ) , Some ( InvoiceFeatures :: known ( ) ) , None , & Vec :: new ( ) , 3_000_000 , 50 , nodes[ 0 ] . logger ) . unwrap ( ) ;
7753
+ send_along_route ( & nodes[ 1 ] , route, & [ & nodes[ 0 ] ] , 3_000_000 ) ;
7749
7754
7750
7755
let revoked_local_txn = get_local_commitment_txn ! ( nodes[ 1 ] , chan. 2 ) ;
7751
7756
assert_eq ! ( revoked_local_txn[ 0 ] . input. len( ) , 1 ) ;
@@ -8058,7 +8063,7 @@ fn test_bump_txn_sanitize_tracking_maps() {
8058
8063
claim_payment ( & nodes[ 0 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , payment_preimage) ;
8059
8064
8060
8065
// Broadcast set of revoked txn on A
8061
- connect_blocks ( & nodes[ 0 ] , 52 - CHAN_CONFIRM_DEPTH ) ;
8066
+ connect_blocks ( & nodes[ 0 ] , TEST_FINAL_CLTV + 2 - CHAN_CONFIRM_DEPTH ) ;
8062
8067
expect_pending_htlcs_forwardable_ignore ! ( nodes[ 0 ] ) ;
8063
8068
assert_eq ! ( nodes[ 0 ] . tx_broadcaster. txn_broadcasted. lock( ) . unwrap( ) . len( ) , 0 ) ;
8064
8069
0 commit comments