Skip to content

Commit 8e37c78

Browse files
f remove redundant test util
1 parent aee13e5 commit 8e37c78

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

lightning/src/ln/async_payments_tests.rs

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@
77
// You may not use this file except in accordance with one or both of these
88
// licenses.
99

10-
use crate::blinded_path::message::{BlindedMessagePath, MessageContext, OffersContext};
10+
use crate::blinded_path::message::{MessageContext, OffersContext};
1111
use crate::events::{Event, MessageSendEventsProvider, PaymentFailureReason};
1212
use crate::ln::channelmanager::PaymentId;
1313
use crate::ln::functional_test_utils::*;
14-
use crate::ln::msgs;
1514
use crate::ln::msgs::OnionMessageHandler;
15+
use crate::ln::offers_tests;
1616
use crate::ln::outbound_payment::Retry;
1717
use crate::offers::nonce::Nonce;
1818
use crate::onion_message::async_payments::{
1919
AsyncPaymentsMessage, AsyncPaymentsMessageHandler, ReleaseHeldHtlc,
2020
};
21-
use crate::onion_message::messenger::{
22-
Destination, MessageRouter, MessageSendInstructions, PeeledOnion,
23-
};
21+
use crate::onion_message::messenger::{Destination, MessageRouter, MessageSendInstructions};
2422
use crate::onion_message::offers::OffersMessage;
2523
use crate::onion_message::packet::ParsedOnionMessageContents;
2624
use crate::prelude::*;
@@ -29,27 +27,6 @@ use bitcoin::secp256k1::Secp256k1;
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!(matches!(
39-
invreq,
40-
ParsedOnionMessageContents::Offers(OffersMessage::InvoiceRequest(_))
41-
));
42-
assert!(matches!(
43-
context,
44-
Some(MessageContext::Offers(OffersContext::InvoiceRequest { .. }))
45-
));
46-
reply_path.unwrap()
47-
},
48-
Ok(PeeledOnion::Forward(_, _)) => panic!("Unexpected onion message forward"),
49-
Err(e) => panic!("Failed to process onion message {:?}", e),
50-
}
51-
}
52-
5330
#[test]
5431
#[cfg(async_payments)]
5532
fn static_invoice_unknown_required_features() {
@@ -97,7 +74,7 @@ fn static_invoice_unknown_required_features() {
9774
.onion_messenger
9875
.next_onion_message_for_peer(nodes[1].node.get_our_node_id())
9976
.unwrap();
100-
let invreq_reply_path = extract_invoice_request_reply_path(&nodes[1], &invreq_om);
77+
let invreq_reply_path = offers_tests::extract_invoice_request(&nodes[1], &invreq_om).1;
10178
nodes[1]
10279
.onion_messenger
10380
.send_onion_message(
@@ -169,7 +146,7 @@ fn ignore_unexpected_static_invoice() {
169146
.onion_messenger
170147
.next_onion_message_for_peer(nodes[1].node.get_our_node_id())
171148
.unwrap();
172-
let invreq_reply_path = extract_invoice_request_reply_path(&nodes[1], &invreq_om);
149+
let invreq_reply_path = offers_tests::extract_invoice_request(&nodes[1], &invreq_om).1;
173150

174151
// Create a static invoice to be sent over the reply path containing the original payment_id, but
175152
// the static invoice corresponds to a different offer than was originally paid.
@@ -313,7 +290,7 @@ fn pays_static_invoice() {
313290
.onion_messenger
314291
.next_onion_message_for_peer(nodes[1].node.get_our_node_id())
315292
.unwrap();
316-
let invreq_reply_path = extract_invoice_request_reply_path(&nodes[1], &invreq_om);
293+
let invreq_reply_path = offers_tests::extract_invoice_request(&nodes[1], &invreq_om).1;
317294

318295
nodes[1]
319296
.onion_messenger

lightning/src/ln/offers_tests.rs

Lines changed: 1 addition & 1 deletion
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)