|
8 | 8 | // licenses.
|
9 | 9 |
|
10 | 10 | use bitcoin::secp256k1::Secp256k1;
|
11 |
| -use crate::blinded_path::message::{BlindedMessagePath, MessageContext, OffersContext}; |
| 11 | +use crate::blinded_path::message::{MessageContext, OffersContext}; |
12 | 12 | use crate::events::{Event, MessageSendEventsProvider, PaymentFailureReason};
|
13 | 13 | use crate::ln::channelmanager::PaymentId;
|
14 | 14 | use crate::ln::functional_test_utils::*;
|
15 |
| -use crate::ln::msgs; |
16 | 15 | use crate::ln::msgs::OnionMessageHandler;
|
| 16 | +use crate::ln::offers_tests; |
17 | 17 | use crate::ln::outbound_payment::Retry;
|
18 | 18 | use crate::offers::nonce::Nonce;
|
19 | 19 | use crate::onion_message::async_payments::{
|
20 | 20 | AsyncPaymentsMessage, AsyncPaymentsMessageHandler, ReleaseHeldHtlc,
|
21 | 21 | };
|
22 |
| -use crate::onion_message::messenger::{ |
23 |
| - Destination, MessageRouter, MessageSendInstructions, PeeledOnion, |
24 |
| -}; |
| 22 | +use crate::onion_message::messenger::{Destination, MessageRouter, MessageSendInstructions}; |
25 | 23 | use crate::onion_message::offers::OffersMessage;
|
26 | 24 | use crate::onion_message::packet::ParsedOnionMessageContents;
|
27 | 25 | use crate::prelude::*;
|
28 | 26 | use crate::types::features::Bolt12InvoiceFeatures;
|
29 | 27 |
|
30 | 28 | use core::convert::Infallible;
|
31 | 29 |
|
32 |
| -#[cfg(async_payments)] |
33 |
| -fn extract_invoice_request_reply_path<'a, 'b, 'c>( |
34 |
| - invreq_recipient: &Node<'a, 'b, 'c>, message: &msgs::OnionMessage |
35 |
| -) -> BlindedMessagePath { |
36 |
| - match invreq_recipient.onion_messenger.peel_onion_message(message) { |
37 |
| - Ok(PeeledOnion::Receive(invreq, context, reply_path)) => { |
38 |
| - assert!( |
39 |
| - matches!(invreq, ParsedOnionMessageContents::Offers(OffersMessage::InvoiceRequest(_))) |
40 |
| - ); |
41 |
| - assert!( |
42 |
| - matches!(context, Some(MessageContext::Offers(OffersContext::InvoiceRequest { .. }))) |
43 |
| - ); |
44 |
| - reply_path.unwrap() |
45 |
| - }, |
46 |
| - Ok(PeeledOnion::Forward(_, _)) => panic!("Unexpected onion message forward"), |
47 |
| - Err(e) => panic!("Failed to process onion message {:?}", e), |
48 |
| - } |
49 |
| -} |
50 |
| - |
51 | 30 | #[test]
|
52 | 31 | #[cfg(async_payments)]
|
53 | 32 | fn static_invoice_unknown_required_features() {
|
@@ -82,7 +61,7 @@ fn static_invoice_unknown_required_features() {
|
82 | 61 | // Don't forward the invreq since we don't support retrieving the static invoice from the
|
83 | 62 | // recipient's LSP yet, instead manually construct the response.
|
84 | 63 | let invreq_om = nodes[0].onion_messenger.next_onion_message_for_peer(nodes[1].node.get_our_node_id()).unwrap();
|
85 |
| - let invreq_reply_path = extract_invoice_request_reply_path(&nodes[1], &invreq_om); |
| 64 | + let invreq_reply_path = offers_tests::extract_invoice_request(&nodes[1], &invreq_om).1; |
86 | 65 | nodes[1].onion_messenger.send_onion_message(
|
87 | 66 | ParsedOnionMessageContents::<Infallible>::Offers(OffersMessage::StaticInvoice(static_invoice_unknown_req_features)),
|
88 | 67 | MessageSendInstructions::WithoutReplyPath { destination: Destination::BlindedPath(invreq_reply_path) }
|
@@ -129,7 +108,7 @@ fn ignore_unexpected_static_invoice() {
|
129 | 108 | // Don't forward the invreq since we don't support retrieving the static invoice from the
|
130 | 109 | // recipient's LSP yet, instead manually construct the responses below.
|
131 | 110 | let invreq_om = nodes[0].onion_messenger.next_onion_message_for_peer(nodes[1].node.get_our_node_id()).unwrap();
|
132 |
| - let invreq_reply_path = extract_invoice_request_reply_path(&nodes[1], &invreq_om); |
| 111 | + let invreq_reply_path = offers_tests::extract_invoice_request(&nodes[1], &invreq_om).1; |
133 | 112 |
|
134 | 113 | // Create a static invoice to be sent over the reply path containing the original payment_id, but
|
135 | 114 | // the static invoice corresponds to a different offer than was originally paid.
|
@@ -210,7 +189,7 @@ fn pays_static_invoice() {
|
210 | 189 | // Don't forward the invreq since we don't support retrieving the static invoice from the
|
211 | 190 | // recipient's LSP yet, instead manually construct the response.
|
212 | 191 | let invreq_om = nodes[0].onion_messenger.next_onion_message_for_peer(nodes[1].node.get_our_node_id()).unwrap();
|
213 |
| - let invreq_reply_path = extract_invoice_request_reply_path(&nodes[1], &invreq_om); |
| 192 | + let invreq_reply_path = offers_tests::extract_invoice_request(&nodes[1], &invreq_om).1; |
214 | 193 |
|
215 | 194 | nodes[1].onion_messenger.send_onion_message(
|
216 | 195 | ParsedOnionMessageContents::<Infallible>::Offers(OffersMessage::StaticInvoice(static_invoice)),
|
|
0 commit comments