Skip to content

Commit e6c4abf

Browse files
f remove redundant test util
1 parent ba4a13e commit e6c4abf

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

lightning/src/ln/async_payments_tests.rs

+6-27
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,25 @@
88
// licenses.
99

1010
use bitcoin::secp256k1::Secp256k1;
11-
use crate::blinded_path::message::{BlindedMessagePath, MessageContext, OffersContext};
11+
use crate::blinded_path::message::{MessageContext, OffersContext};
1212
use crate::events::{Event, MessageSendEventsProvider, PaymentFailureReason};
1313
use crate::ln::channelmanager::PaymentId;
1414
use crate::ln::functional_test_utils::*;
15-
use crate::ln::msgs;
1615
use crate::ln::msgs::OnionMessageHandler;
16+
use crate::ln::offers_tests;
1717
use crate::ln::outbound_payment::Retry;
1818
use crate::offers::nonce::Nonce;
1919
use crate::onion_message::async_payments::{
2020
AsyncPaymentsMessage, AsyncPaymentsMessageHandler, ReleaseHeldHtlc,
2121
};
22-
use crate::onion_message::messenger::{
23-
Destination, MessageRouter, MessageSendInstructions, PeeledOnion,
24-
};
22+
use crate::onion_message::messenger::{Destination, MessageRouter, MessageSendInstructions};
2523
use crate::onion_message::offers::OffersMessage;
2624
use crate::onion_message::packet::ParsedOnionMessageContents;
2725
use crate::prelude::*;
2826
use crate::types::features::Bolt12InvoiceFeatures;
2927

3028
use core::convert::Infallible;
3129

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-
5130
#[test]
5231
#[cfg(async_payments)]
5332
fn static_invoice_unknown_required_features() {
@@ -82,7 +61,7 @@ fn static_invoice_unknown_required_features() {
8261
// Don't forward the invreq since we don't support retrieving the static invoice from the
8362
// recipient's LSP yet, instead manually construct the response.
8463
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;
8665
nodes[1].onion_messenger.send_onion_message(
8766
ParsedOnionMessageContents::<Infallible>::Offers(OffersMessage::StaticInvoice(static_invoice_unknown_req_features)),
8867
MessageSendInstructions::WithoutReplyPath { destination: Destination::BlindedPath(invreq_reply_path) }
@@ -129,7 +108,7 @@ fn ignore_unexpected_static_invoice() {
129108
// Don't forward the invreq since we don't support retrieving the static invoice from the
130109
// recipient's LSP yet, instead manually construct the responses below.
131110
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;
133112

134113
// Create a static invoice to be sent over the reply path containing the original payment_id, but
135114
// the static invoice corresponds to a different offer than was originally paid.
@@ -210,7 +189,7 @@ fn pays_static_invoice() {
210189
// Don't forward the invreq since we don't support retrieving the static invoice from the
211190
// recipient's LSP yet, instead manually construct the response.
212191
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;
214193

215194
nodes[1].onion_messenger.send_onion_message(
216195
ParsedOnionMessageContents::<Infallible>::Offers(OffersMessage::StaticInvoice(static_invoice)),

lightning/src/ln/offers_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn extract_offer_nonce<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, message: &OnionMessa
199199
}
200200
}
201201

202-
fn extract_invoice_request<'a, 'b, 'c>(
202+
pub(super) fn extract_invoice_request<'a, 'b, 'c>(
203203
node: &Node<'a, 'b, 'c>, message: &OnionMessage
204204
) -> (InvoiceRequest, BlindedMessagePath) {
205205
match node.onion_messenger.peel_onion_message(message) {

0 commit comments

Comments
 (0)