@@ -2810,6 +2810,7 @@ fn process_failure_packet(
2810
2810
2811
2811
#[ cfg( test) ]
2812
2812
mod tests {
2813
+ use core:: iter;
2813
2814
use std:: sync:: Arc ;
2814
2815
2815
2816
use crate :: io;
@@ -3153,14 +3154,18 @@ mod tests {
3153
3154
3154
3155
for mutation_type in failure_mutations
3155
3156
. chain ( attribution_data_mutations. map ( MutationType :: AttributionData ) )
3157
+ . chain ( iter:: once ( MutationType :: DropAttributionData ) )
3156
3158
{
3159
+ // If the mutation is in the attribution data and not in the failure message itself, the invalid
3160
+ // attribution data should be ignored and the failure should still surface.
3161
+ let failure_ok = matches ! ( mutation_type, MutationType :: DropAttributionData )
3162
+ || matches ! ( mutation_type, MutationType :: AttributionData ( _) ) ;
3163
+
3157
3164
let mutation = Mutation { node : mutating_node, mutation_type } ;
3158
3165
let decrypted_failure =
3159
3166
test_attributable_failure_packet_onion_with_mutation ( Some ( mutation) ) ;
3160
3167
3161
- // If the mutation is in the attribution data and not in the failure message itself, the invalid
3162
- // attribution data should be ignored and the failure should still surface.
3163
- if mutated_index >= FAILURE_MESSAGE_LEN {
3168
+ if failure_ok {
3164
3169
assert_eq ! (
3165
3170
decrypted_failure. onion_error_code,
3166
3171
Some ( LocalHTLCFailureReason :: IncorrectPaymentDetails )
@@ -3198,6 +3203,7 @@ mod tests {
3198
3203
enum MutationType {
3199
3204
FailureMessage ( usize ) ,
3200
3205
AttributionData ( AttributionDataMutationType ) ,
3206
+ DropAttributionData ,
3201
3207
}
3202
3208
3203
3209
struct Mutation {
@@ -3285,6 +3291,10 @@ mod tests {
3285
3291
// Mutate hold times.
3286
3292
packet. attribution_data . as_mut ( ) . unwrap ( ) . hmacs [ * i] ^= 1 ;
3287
3293
} ,
3294
+ MutationType :: DropAttributionData => {
3295
+ // Drop attribution data completely. This simulates a node that does not support the feature.
3296
+ packet. attribution_data = None ;
3297
+ } ,
3288
3298
}
3289
3299
} ;
3290
3300
0 commit comments