@@ -1014,7 +1014,7 @@ where
1014
1014
return ;
1015
1015
}
1016
1016
1017
- log_info ! ( logger, "Processing index {} of {}" , route_hop_idx, path. hops. len( ) ) ;
1017
+ // log_info!(logger, "Processing index {} of {}", route_hop_idx, path.hops.len());
1018
1018
1019
1019
let route_hop = match route_hop_opt {
1020
1020
Some ( hop) => hop,
@@ -1106,11 +1106,11 @@ where
1106
1106
failed_within_blinded_path : false ,
1107
1107
} ) ;
1108
1108
1109
- log_debug ! ( logger, "Invalid HMAC in onion failure packet at pos {}" , route_hop_idx) ;
1109
+ // log_debug!(logger, "Invalid HMAC in onion failure packet at pos {}", route_hop_idx);
1110
1110
1111
1111
return ;
1112
1112
} else {
1113
- log_debug ! ( logger, "Valid HMAC in onion failure packet at pos {}" , route_hop_idx) ;
1113
+ // log_debug!(logger, "Valid HMAC in onion failure packet at pos {}", route_hop_idx);
1114
1114
}
1115
1115
1116
1116
// Shift payloads left.
@@ -2006,22 +2006,22 @@ use crate::util::test_utils::TestLogger;
2006
2006
RouteHop {
2007
2007
pubkey: PublicKey :: from_slice( & <Vec <u8 >>:: from_hex( "0324653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c" ) . unwrap( ) [ ..] ) . unwrap( ) ,
2008
2008
channel_features: ChannelFeatures :: empty( ) , node_features: NodeFeatures :: empty( ) ,
2009
- short_channel_id: 0 , fee_msat: 0 , cltv_expiry_delta: 0 , maybe_announced_channel: true , // We fill in the payloads manually instead of generating them from RouteHops.
2009
+ short_channel_id: 1 , fee_msat: 0 , cltv_expiry_delta: 0 , maybe_announced_channel: true , // We fill in the payloads manually instead of generating them from RouteHops.
2010
2010
} ,
2011
2011
RouteHop {
2012
2012
pubkey: PublicKey :: from_slice( & <Vec <u8 >>:: from_hex( "027f31ebc5462c1fdce1b737ecff52d37d75dea43ce11c74d25aa297165faa2007" ) . unwrap( ) [ ..] ) . unwrap( ) ,
2013
2013
channel_features: ChannelFeatures :: empty( ) , node_features: NodeFeatures :: empty( ) ,
2014
- short_channel_id: 0 , fee_msat: 0 , cltv_expiry_delta: 0 , maybe_announced_channel: true , // We fill in the payloads manually instead of generating them from RouteHops.
2014
+ short_channel_id: 2 , fee_msat: 0 , cltv_expiry_delta: 0 , maybe_announced_channel: true , // We fill in the payloads manually instead of generating them from RouteHops.
2015
2015
} ,
2016
2016
RouteHop {
2017
2017
pubkey: PublicKey :: from_slice( & <Vec <u8 >>:: from_hex( "032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991" ) . unwrap( ) [ ..] ) . unwrap( ) ,
2018
2018
channel_features: ChannelFeatures :: empty( ) , node_features: NodeFeatures :: empty( ) ,
2019
- short_channel_id: 0 , fee_msat: 0 , cltv_expiry_delta: 0 , maybe_announced_channel: true , // We fill in the payloads manually instead of generating them from RouteHops.
2019
+ short_channel_id: 3 , fee_msat: 0 , cltv_expiry_delta: 0 , maybe_announced_channel: true , // We fill in the payloads manually instead of generating them from RouteHops.
2020
2020
} ,
2021
2021
RouteHop {
2022
2022
pubkey: PublicKey :: from_slice( & <Vec <u8 >>:: from_hex( "02edabbd16b41c8371b92ef2f04c1185b4f03b6dcd52ba9b78d9d7c89c8f221145" ) . unwrap( ) [ ..] ) . unwrap( ) ,
2023
2023
channel_features: ChannelFeatures :: empty( ) , node_features: NodeFeatures :: empty( ) ,
2024
- short_channel_id: 0 , fee_msat: 0 , cltv_expiry_delta: 0 , maybe_announced_channel: true , // We fill in the payloads manually instead of generating them from RouteHops.
2024
+ short_channel_id: 4 , fee_msat: 0 , cltv_expiry_delta: 0 , maybe_announced_channel: true , // We fill in the payloads manually instead of generating them from RouteHops.
2025
2025
} ,
2026
2026
] , blinded_tail : None }
2027
2027
}
@@ -2327,28 +2327,20 @@ use crate::util::test_utils::TestLogger;
2327
2327
set_max_path_length ( & mut route_params, & recipient_onion, None , None , 42 ) . unwrap ( ) ;
2328
2328
}
2329
2329
2330
- // #[test]
2331
- // fn test_attributable_failure_packet_onion() {
2332
- // const EXPECT_FAILURE: &str = "400f0000000000000064000c3500fd84d1fd012c808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080";
2333
-
2334
- // for mutating_node in 0..5 {
2335
- // for mutated_index in 0..1968 {
2336
- // println!("Testing mutation {} on node {}", mutated_index, mutating_node);
2337
-
2338
- // let decrypted_failure = test_attributable_failure_packet_onion_with_mutation(mutating_node, mutated_index);
2339
-
2340
- // match decrypted_failure.result {
2341
- // AttributableFailureResult::Success(success) => {
2342
- // assert_eq!(success.message.to_lower_hex_string(), EXPECT_FAILURE);
2343
- // assert_eq!(decrypted_failure.failure_index, 4);
2344
- // }
2345
- // AttributableFailureResult::InvalidPayload | AttributableFailureResult::InvalidHmac => {
2346
- // assert_eq!(decrypted_failure.failure_index, 4-mutating_node);
2347
- // }
2348
- // }
2349
- // }
2350
- // }
2351
- // }
2330
+ #[ test]
2331
+ fn test_attributable_failure_packet_onion_mutations ( ) {
2332
+ for mutating_node in 0 ..5 {
2333
+ for mutated_index in 0 ..1060 +920 {
2334
+ let decrypted_failure = test_attributable_failure_packet_onion_with_mutation ( mutating_node, mutated_index) ;
2335
+
2336
+ // if let Some(chan_id) = decrypted_failure.short_channel_id {
2337
+ // println!("Testing mutation {} on node {}: chan failure at {}", mutated_index, mutating_node, chan_id);
2338
+ // }
2339
+
2340
+ assert ! ( decrypted_failure. onion_error_code == Some ( 16399 ) || decrypted_failure. short_channel_id. is_some( ) ) ;
2341
+ }
2342
+ }
2343
+ }
2352
2344
2353
2345
#[ test]
2354
2346
fn test_attributable_failure_packet_onion_happy ( ) {
@@ -2388,13 +2380,22 @@ use crate::util::test_utils::TestLogger;
2388
2380
2389
2381
let logger: Arc < TestLogger > = Arc :: new ( TestLogger :: new ( ) ) ;
2390
2382
2391
- // if mutating_node == 0 {
2392
- // packet_slice[mutated_index] ^= 1;
2393
- // }
2394
-
2395
2383
let mut encrypted_packet = super :: encrypt_failure_packet ( onion_keys[ 4 ] . shared_secret . as_ref ( ) , & onion_error) ;
2396
2384
// assert_eq!(encrypted_packet.data.to_lower_hex_string(), EXPECTED_MESSAGES[0]);
2397
2385
2386
+ let mutate_packet = |packet : & mut OnionErrorPacket , mutated_index| {
2387
+ let data_len = packet. data . len ( ) ;
2388
+ if mutated_index < data_len {
2389
+ packet. data [ mutated_index] ^= 1 ;
2390
+ } else {
2391
+ packet. attribution_data [ mutated_index - data_len] ^= 1 ;
2392
+ }
2393
+ } ;
2394
+
2395
+ if mutating_node == 0 {
2396
+ mutate_packet ( & mut encrypted_packet, mutated_index) ;
2397
+ }
2398
+
2398
2399
for idx in 1 ..5 {
2399
2400
2400
2401
let shared_secret = onion_keys[ 4 - idx] . shared_secret . as_ref ( ) ;
@@ -2403,9 +2404,10 @@ use crate::util::test_utils::TestLogger;
2403
2404
process_failure_packet ( & mut encrypted_packet, shared_secret, & payload) ;
2404
2405
encrypted_packet = super :: encrypt_failure_packet ( shared_secret, & encrypted_packet) ;
2405
2406
2406
- // if idx == mutating_node {
2407
- // encrypted_packet.data[mutated_index] ^= 1;
2408
- // }
2407
+ if mutating_node == idx {
2408
+ mutate_packet ( & mut encrypted_packet, mutated_index) ;
2409
+ }
2410
+
2409
2411
// assert_eq!(encrypted_packet.data.to_lower_hex_string(), EXPECTED_MESSAGES[idx]);
2410
2412
}
2411
2413
0 commit comments