Skip to content

Commit 077992d

Browse files
committed
fix tests
1 parent 6c18c8c commit 077992d

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

lightning/src/ln/channel.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10712,7 +10712,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1071210712
} else {
1071310713
None
1071410714
}
10715-
} else {
10715+
} else {
1071610716
None
1071710717
}
1071810718
);
@@ -11568,7 +11568,7 @@ mod tests {
1156811568
htlc_id: 0,
1156911569
};
1157011570
let dummy_holding_cell_failed_htlc = |htlc_id| HTLCUpdateAwaitingACK::FailHTLC {
11571-
htlc_id, err_packet: msgs::OnionErrorPacket { data: vec![42], attribution_data: [0; ATTRIBUTION_DATA_LEN] }
11571+
htlc_id, err_packet: msgs::OnionErrorPacket { data: vec![42], attribution_data: Some([0; ATTRIBUTION_DATA_LEN]) }
1157211572
};
1157311573
let dummy_holding_cell_malformed_htlc = |htlc_id| HTLCUpdateAwaitingACK::FailMalformedHTLC {
1157411574
htlc_id, failure_code: INVALID_ONION_BLINDING, sha256_of_onion: [0; 32],

lightning/src/ln/channelmanager.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16298,7 +16298,7 @@ use crate::ln::types::ChannelId;
1629816298
let mut nodes = create_network(1, &node_cfg, &chanmgrs);
1629916299

1630016300
let dummy_failed_htlc = |htlc_id| {
16301-
HTLCForwardInfo::FailHTLC { htlc_id, err_packet: msgs::OnionErrorPacket { data: vec![42], attribution_data: [0; ATTRIBUTION_DATA_LEN] } }
16301+
HTLCForwardInfo::FailHTLC { htlc_id, err_packet: msgs::OnionErrorPacket { data: vec![42], attribution_data: Some([0; ATTRIBUTION_DATA_LEN]) } }
1630216302
};
1630316303
let dummy_malformed_htlc = |htlc_id| {
1630416304
HTLCForwardInfo::FailMalformedHTLC { htlc_id, failure_code: 0x4000, sha256_of_onion: [0; 32] }

lightning/src/ln/onion_route_tests.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ fn test_onion_failure() {
418418
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
419419
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[0].shared_secret.as_ref(), NODE|2, &[0;0]);
420420
msg.reason = failure.data;
421-
msg.attribution_data = Some(failure.attribution_data);
421+
msg.attribution_data = failure.attribution_data;
422422
}, ||{}, true, Some(NODE|2), Some(NetworkUpdate::NodeFailure{node_id: route.paths[0].hops[0].pubkey, is_permanent: false}), Some(route.paths[0].hops[0].short_channel_id), Some(next_hop_failure.clone()));
423423

424424
// final node failure
@@ -428,7 +428,7 @@ fn test_onion_failure() {
428428
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
429429
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[1].shared_secret.as_ref(), NODE|2, &[0;0]);
430430
msg.reason = failure.data;
431-
msg.attribution_data = Some(failure.attribution_data);
431+
msg.attribution_data = failure.attribution_data;
432432
}, ||{
433433
nodes[2].node.fail_htlc_backwards(&payment_hash);
434434
}, true, Some(NODE|2), Some(NetworkUpdate::NodeFailure{node_id: route.paths[0].hops[1].pubkey, is_permanent: false}), Some(route.paths[0].hops[1].short_channel_id), None);
@@ -442,7 +442,7 @@ fn test_onion_failure() {
442442
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
443443
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[0].shared_secret.as_ref(), PERM|NODE|2, &[0;0]);
444444
msg.reason = failure.data;
445-
msg.attribution_data = Some(failure.attribution_data);
445+
msg.attribution_data = failure.attribution_data;
446446
}, ||{}, true, Some(PERM|NODE|2), Some(NetworkUpdate::NodeFailure{node_id: route.paths[0].hops[0].pubkey, is_permanent: true}), Some(route.paths[0].hops[0].short_channel_id), Some(next_hop_failure.clone()));
447447

448448
// final node failure
@@ -451,7 +451,7 @@ fn test_onion_failure() {
451451
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
452452
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[1].shared_secret.as_ref(), PERM|NODE|2, &[0;0]);
453453
msg.reason = failure.data;
454-
msg.attribution_data = Some(failure.attribution_data);
454+
msg.attribution_data = failure.attribution_data;
455455
}, ||{
456456
nodes[2].node.fail_htlc_backwards(&payment_hash);
457457
}, false, Some(PERM|NODE|2), Some(NetworkUpdate::NodeFailure{node_id: route.paths[0].hops[1].pubkey, is_permanent: true}), Some(route.paths[0].hops[1].short_channel_id), None);
@@ -465,7 +465,7 @@ fn test_onion_failure() {
465465
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
466466
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[0].shared_secret.as_ref(), PERM|NODE|3, &[0;0]);
467467
msg.reason = failure.data;
468-
msg.attribution_data = Some(failure.attribution_data);
468+
msg.attribution_data = failure.attribution_data;
469469
}, ||{
470470
nodes[2].node.fail_htlc_backwards(&payment_hash);
471471
}, true, Some(PERM|NODE|3), Some(NetworkUpdate::NodeFailure{node_id: route.paths[0].hops[0].pubkey, is_permanent: true}), Some(route.paths[0].hops[0].short_channel_id), Some(next_hop_failure.clone()));
@@ -476,7 +476,7 @@ fn test_onion_failure() {
476476
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
477477
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[1].shared_secret.as_ref(), PERM|NODE|3, &[0;0]);
478478
msg.reason = failure.data;
479-
msg.attribution_data = Some(failure.attribution_data);
479+
msg.attribution_data = failure.attribution_data;
480480
}, ||{
481481
nodes[2].node.fail_htlc_backwards(&payment_hash);
482482
}, false, Some(PERM|NODE|3), Some(NetworkUpdate::NodeFailure{node_id: route.paths[0].hops[1].pubkey, is_permanent: true}), Some(route.paths[0].hops[1].short_channel_id), None);
@@ -508,7 +508,7 @@ fn test_onion_failure() {
508508
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
509509
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[0].shared_secret.as_ref(), UPDATE|7, &err_data);
510510
msg.reason = failure.data;
511-
msg.attribution_data = Some(failure.attribution_data);
511+
msg.attribution_data = failure.attribution_data;
512512
}, ||{}, true, Some(UPDATE|7),
513513
Some(NetworkUpdate::ChannelFailure { short_channel_id, is_permanent: false }),
514514
Some(short_channel_id), Some(next_hop_failure.clone()));
@@ -522,7 +522,7 @@ fn test_onion_failure() {
522522
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
523523
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[0].shared_secret.as_ref(), UPDATE|7, &err_data_without_type);
524524
msg.reason = failure.data;
525-
msg.attribution_data = Some(failure.attribution_data);
525+
msg.attribution_data = failure.attribution_data;
526526
}, ||{}, true, Some(UPDATE|7),
527527
Some(NetworkUpdate::ChannelFailure { short_channel_id, is_permanent: false }),
528528
Some(short_channel_id), Some(next_hop_failure.clone()));
@@ -535,7 +535,7 @@ fn test_onion_failure() {
535535
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
536536
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[0].shared_secret.as_ref(), PERM|8, &[0;0]);
537537
msg.reason = failure.data;
538-
msg.attribution_data = Some(failure.attribution_data);
538+
msg.attribution_data = failure.attribution_data;
539539
// short_channel_id from the processing node
540540
}, ||{}, true, Some(PERM|8), Some(NetworkUpdate::ChannelFailure{short_channel_id, is_permanent: true}), Some(short_channel_id), Some(next_hop_failure.clone()));
541541

@@ -547,7 +547,7 @@ fn test_onion_failure() {
547547
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
548548
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[0].shared_secret.as_ref(), PERM|9, &[0;0]);
549549
msg.reason = failure.data;
550-
msg.attribution_data = Some(failure.attribution_data);
550+
msg.attribution_data = failure.attribution_data;
551551
// short_channel_id from the processing node
552552
}, ||{}, true, Some(PERM|9), Some(NetworkUpdate::ChannelFailure{short_channel_id, is_permanent: true}), Some(short_channel_id), Some(next_hop_failure.clone()));
553553

@@ -681,7 +681,7 @@ fn test_onion_failure() {
681681
let onion_keys = onion_utils::construct_onion_keys(&Secp256k1::new(), &route.paths[0], &session_priv).unwrap();
682682
let failure = onion_utils::build_first_hop_failure_packet(onion_keys[1].shared_secret.as_ref(), 23, &[0;0]);
683683
msg.reason = failure.data;
684-
msg.attribution_data = Some(failure.attribution_data);
684+
msg.attribution_data = failure.attribution_data;
685685
}, ||{
686686
nodes[2].node.fail_htlc_backwards(&payment_hash);
687687
}, true, Some(23), None, None, None);
@@ -701,12 +701,12 @@ fn test_onion_failure() {
701701
decoded_err_packet.hmac = Hmac::from_engine(hmac).to_byte_array();
702702
let onion_error = OnionErrorPacket{
703703
data: decoded_err_packet.encode(),
704-
attribution_data: [0; ATTRIBUTION_DATA_LEN],
704+
attribution_data: Some([0; ATTRIBUTION_DATA_LEN]),
705705
};
706706
let failure = onion_utils::encrypt_failure_packet(
707707
&onion_keys[1].shared_secret.as_ref(), &onion_error);
708708
msg.reason = failure.data;
709-
msg.attribution_data = Some(failure.attribution_data);
709+
msg.attribution_data = failure.attribution_data;
710710
}, || nodes[2].node.fail_htlc_backwards(&payment_hash), false, None,
711711
Some(NetworkUpdate::NodeFailure { node_id: route.paths[0].hops[1].pubkey, is_permanent: true }),
712712
Some(channels[1].0.contents.short_channel_id), None);
@@ -730,7 +730,7 @@ fn test_onion_failure() {
730730
decoded_err_packet.hmac = Hmac::from_engine(hmac).to_byte_array();
731731
let onion_error = OnionErrorPacket{
732732
data: decoded_err_packet.encode(),
733-
attribution_data: [0; ATTRIBUTION_DATA_LEN],
733+
attribution_data: Some([0; ATTRIBUTION_DATA_LEN]),
734734
};
735735
let failure = onion_utils::encrypt_failure_packet(
736736
&onion_keys[0].shared_secret.as_ref(), &onion_error);
@@ -758,7 +758,7 @@ fn test_onion_failure() {
758758
decoded_err_packet.hmac = Hmac::from_engine(hmac).to_byte_array();
759759
let onion_error = OnionErrorPacket{
760760
data: decoded_err_packet.encode(),
761-
attribution_data: [0; ATTRIBUTION_DATA_LEN],
761+
attribution_data: Some([0; ATTRIBUTION_DATA_LEN]),
762762
};
763763
let failure = onion_utils::encrypt_failure_packet(
764764
&onion_keys[1].shared_secret.as_ref(), &onion_error);

lightning/src/ln/onion_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,7 @@ use crate::util::test_utils::TestLogger;
23962396
if mutated_index < data_len {
23972397
packet.data[mutated_index] ^= 1;
23982398
} else {
2399-
packet.attribution_data[mutated_index - data_len] ^= 1;
2399+
packet.attribution_data.as_mut().unwrap()[mutated_index - data_len] ^= 1;
24002400
}
24012401
};
24022402

0 commit comments

Comments
 (0)