Skip to content

Commit fe8338c

Browse files
committed
f check_dummy_hopd_path_length instead of padding, as its about hops
1 parent 94c7f9e commit fe8338c

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

lightning/src/ln/offers_tests.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn check_compact_path_introduction_node<'a, 'b, 'c>(
163163
&& matches!(path.introduction_node(), IntroductionNode::DirectedShortChannelId(..))
164164
}
165165

166-
fn check_padded_path_length<'a, 'b, 'c>(
166+
fn check_dummy_hopd_path_length<'a, 'b, 'c>(
167167
path: &BlindedMessagePath,
168168
lookup_node: &Node<'a, 'b, 'c>,
169169
expected_introduction_node: PublicKey,
@@ -491,7 +491,7 @@ fn check_dummy_hop_pattern_in_offer() {
491491

492492
assert_eq!(invoice_request.amount_msats(), Some(10_000_000));
493493
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);
494-
assert!(check_padded_path_length(&reply_path, alice, bob_id, PADDED_PATH_LENGTH));
494+
assert!(check_dummy_hopd_path_length(&reply_path, alice, bob_id, PADDED_PATH_LENGTH));
495495

496496
// Case 2: NodeIdMessageRouter → uses node ID-based blinded paths
497497
// Expected: Also padded to QR_CODED_PADDED_PATH_LENGTH for QR code size optimization
@@ -513,7 +513,7 @@ fn check_dummy_hop_pattern_in_offer() {
513513

514514
assert_eq!(invoice_request.amount_msats(), Some(10_000_000));
515515
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);
516-
assert!(check_padded_path_length(&reply_path, alice, bob_id, PADDED_PATH_LENGTH));
516+
assert!(check_dummy_hopd_path_length(&reply_path, alice, bob_id, PADDED_PATH_LENGTH));
517517
}
518518

519519
/// Checks that blinded paths are compact for short-lived offers.
@@ -698,7 +698,7 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
698698
});
699699
assert_eq!(invoice_request.amount_msats(), Some(10_000_000));
700700
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
701-
assert!(check_padded_path_length(&reply_path, bob, charlie_id, PADDED_PATH_LENGTH));
701+
assert!(check_dummy_hopd_path_length(&reply_path, bob, charlie_id, PADDED_PATH_LENGTH));
702702

703703
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
704704
charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);
@@ -717,8 +717,8 @@ fn creates_and_pays_for_offer_using_two_hop_blinded_path() {
717717
// to Alice when she's handling the message. Therefore, either Bob or Charlie could
718718
// serve as the introduction node for the reply path back to Alice.
719719
assert!(
720-
check_padded_path_length(&reply_path, david, bob_id, PADDED_PATH_LENGTH) ||
721-
check_padded_path_length(&reply_path, david, charlie_id, PADDED_PATH_LENGTH)
720+
check_dummy_hopd_path_length(&reply_path, david, bob_id, PADDED_PATH_LENGTH) ||
721+
check_dummy_hopd_path_length(&reply_path, david, charlie_id, PADDED_PATH_LENGTH)
722722
);
723723

724724
route_bolt12_payment(david, &[charlie, bob, alice], &invoice);
@@ -801,7 +801,7 @@ fn creates_and_pays_for_refund_using_two_hop_blinded_path() {
801801
for path in invoice.payment_paths() {
802802
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(bob_id));
803803
}
804-
assert!(check_padded_path_length(&reply_path, alice, bob_id, PADDED_PATH_LENGTH));
804+
assert!(check_dummy_hopd_path_length(&reply_path, alice, bob_id, PADDED_PATH_LENGTH));
805805

806806
route_bolt12_payment(david, &[charlie, bob, alice], &invoice);
807807
expect_recent_payment!(david, RecentPaymentDetails::Pending, payment_id);
@@ -856,7 +856,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
856856
});
857857
assert_eq!(invoice_request.amount_msats(), Some(10_000_000));
858858
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);
859-
assert!(check_padded_path_length(&reply_path, alice, bob_id, PADDED_PATH_LENGTH));
859+
assert!(check_dummy_hopd_path_length(&reply_path, alice, bob_id, PADDED_PATH_LENGTH));
860860

861861
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
862862
bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
@@ -868,7 +868,7 @@ fn creates_and_pays_for_offer_using_one_hop_blinded_path() {
868868
for path in invoice.payment_paths() {
869869
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
870870
}
871-
assert!(check_padded_path_length(&reply_path, bob, alice_id, PADDED_PATH_LENGTH));
871+
assert!(check_dummy_hopd_path_length(&reply_path, bob, alice_id, PADDED_PATH_LENGTH));
872872

873873
route_bolt12_payment(bob, &[alice], &invoice);
874874
expect_recent_payment!(bob, RecentPaymentDetails::Pending, payment_id);
@@ -924,7 +924,7 @@ fn creates_and_pays_for_refund_using_one_hop_blinded_path() {
924924
for path in invoice.payment_paths() {
925925
assert_eq!(path.introduction_node(), &IntroductionNode::NodeId(alice_id));
926926
}
927-
assert!(check_padded_path_length(&reply_path, bob, alice_id, PADDED_PATH_LENGTH));
927+
assert!(check_dummy_hopd_path_length(&reply_path, bob, alice_id, PADDED_PATH_LENGTH));
928928

929929
route_bolt12_payment(bob, &[alice], &invoice);
930930
expect_recent_payment!(bob, RecentPaymentDetails::Pending, payment_id);
@@ -1101,7 +1101,7 @@ fn send_invoice_requests_with_distinct_reply_path() {
11011101
alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
11021102

11031103
let (_, reply_path) = extract_invoice_request(alice, &onion_message);
1104-
assert!(check_padded_path_length(&reply_path, alice, charlie_id, PADDED_PATH_LENGTH));
1104+
assert!(check_dummy_hopd_path_length(&reply_path, alice, charlie_id, PADDED_PATH_LENGTH));
11051105

11061106
// Send, extract and verify the second Invoice Request message
11071107
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
@@ -1111,7 +1111,7 @@ fn send_invoice_requests_with_distinct_reply_path() {
11111111
alice.onion_messenger.handle_onion_message(bob_id, &onion_message);
11121112

11131113
let (_, reply_path) = extract_invoice_request(alice, &onion_message);
1114-
assert!(check_padded_path_length(&reply_path, alice, frank_id, PADDED_PATH_LENGTH));
1114+
assert!(check_dummy_hopd_path_length(&reply_path, alice, frank_id, PADDED_PATH_LENGTH));
11151115
}
11161116

11171117
/// This test checks that when multiple potential introduction nodes are available for the payee,
@@ -1182,7 +1182,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
11821182
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
11831183

11841184
let (_, reply_path) = extract_invoice(alice, &onion_message);
1185-
assert!(check_padded_path_length(&reply_path, alice, charlie_id, PADDED_PATH_LENGTH));
1185+
assert!(check_dummy_hopd_path_length(&reply_path, alice, charlie_id, PADDED_PATH_LENGTH));
11861186

11871187
// Send, extract and verify the second Invoice Request message
11881188
let onion_message = david.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
@@ -1191,7 +1191,7 @@ fn send_invoice_for_refund_with_distinct_reply_path() {
11911191
let onion_message = bob.onion_messenger.next_onion_message_for_peer(alice_id).unwrap();
11921192

11931193
let (_, reply_path) = extract_invoice(alice, &onion_message);
1194-
assert!(check_padded_path_length(&reply_path, alice, nodes[6].node.get_our_node_id(), PADDED_PATH_LENGTH));
1194+
assert!(check_dummy_hopd_path_length(&reply_path, alice, nodes[6].node.get_our_node_id(), PADDED_PATH_LENGTH));
11951195
}
11961196

11971197
/// Verifies that the invoice request message can be retried if it fails to reach the
@@ -1245,7 +1245,7 @@ fn creates_and_pays_for_offer_with_retry() {
12451245
});
12461246
assert_eq!(invoice_request.amount_msats(), Some(10_000_000));
12471247
assert_ne!(invoice_request.payer_signing_pubkey(), bob_id);
1248-
assert!(check_padded_path_length(&reply_path, alice, bob_id, PADDED_PATH_LENGTH));
1248+
assert!(check_dummy_hopd_path_length(&reply_path, alice, bob_id, PADDED_PATH_LENGTH));
12491249
let onion_message = alice.onion_messenger.next_onion_message_for_peer(bob_id).unwrap();
12501250
bob.onion_messenger.handle_onion_message(alice_id, &onion_message);
12511251

@@ -1546,7 +1546,7 @@ fn fails_authentication_when_handling_invoice_request() {
15461546
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
15471547
assert_eq!(invoice_request.amount_msats(), Some(10_000_000));
15481548
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
1549-
assert!(check_padded_path_length(&reply_path, david, charlie_id, PADDED_PATH_LENGTH));
1549+
assert!(check_dummy_hopd_path_length(&reply_path, david, charlie_id, PADDED_PATH_LENGTH));
15501550

15511551
assert_eq!(alice.onion_messenger.next_onion_message_for_peer(charlie_id), None);
15521552

@@ -1575,7 +1575,7 @@ fn fails_authentication_when_handling_invoice_request() {
15751575
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
15761576
assert_eq!(invoice_request.amount_msats(), Some(10_000_000));
15771577
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
1578-
assert!(check_padded_path_length(&reply_path, david, charlie_id, PADDED_PATH_LENGTH));
1578+
assert!(check_dummy_hopd_path_length(&reply_path, david, charlie_id, PADDED_PATH_LENGTH));
15791579

15801580
assert_eq!(alice.onion_messenger.next_onion_message_for_peer(charlie_id), None);
15811581
}
@@ -1675,7 +1675,7 @@ fn fails_authentication_when_handling_invoice_for_offer() {
16751675
let (invoice_request, reply_path) = extract_invoice_request(alice, &onion_message);
16761676
assert_eq!(invoice_request.amount_msats(), Some(10_000_000));
16771677
assert_ne!(invoice_request.payer_signing_pubkey(), david_id);
1678-
assert!(check_padded_path_length(&reply_path, david, charlie_id, PADDED_PATH_LENGTH));
1678+
assert!(check_dummy_hopd_path_length(&reply_path, david, charlie_id, PADDED_PATH_LENGTH));
16791679

16801680
let onion_message = alice.onion_messenger.next_onion_message_for_peer(charlie_id).unwrap();
16811681
charlie.onion_messenger.handle_onion_message(alice_id, &onion_message);

0 commit comments

Comments
 (0)