Skip to content

Commit

Permalink
f remove redundant test util
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinewallace committed Jan 6, 2025
1 parent aee13e5 commit 8e37c78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
35 changes: 6 additions & 29 deletions lightning/src/ln/async_payments_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
// You may not use this file except in accordance with one or both of these
// licenses.

use crate::blinded_path::message::{BlindedMessagePath, MessageContext, OffersContext};
use crate::blinded_path::message::{MessageContext, OffersContext};
use crate::events::{Event, MessageSendEventsProvider, PaymentFailureReason};
use crate::ln::channelmanager::PaymentId;
use crate::ln::functional_test_utils::*;
use crate::ln::msgs;
use crate::ln::msgs::OnionMessageHandler;
use crate::ln::offers_tests;
use crate::ln::outbound_payment::Retry;
use crate::offers::nonce::Nonce;
use crate::onion_message::async_payments::{
AsyncPaymentsMessage, AsyncPaymentsMessageHandler, ReleaseHeldHtlc,
};
use crate::onion_message::messenger::{
Destination, MessageRouter, MessageSendInstructions, PeeledOnion,
};
use crate::onion_message::messenger::{Destination, MessageRouter, MessageSendInstructions};
use crate::onion_message::offers::OffersMessage;
use crate::onion_message::packet::ParsedOnionMessageContents;
use crate::prelude::*;
Expand All @@ -29,27 +27,6 @@ use bitcoin::secp256k1::Secp256k1;

use core::convert::Infallible;

#[cfg(async_payments)]
fn extract_invoice_request_reply_path<'a, 'b, 'c>(
invreq_recipient: &Node<'a, 'b, 'c>, message: &msgs::OnionMessage,
) -> BlindedMessagePath {
match invreq_recipient.onion_messenger.peel_onion_message(message) {
Ok(PeeledOnion::Receive(invreq, context, reply_path)) => {
assert!(matches!(
invreq,
ParsedOnionMessageContents::Offers(OffersMessage::InvoiceRequest(_))
));
assert!(matches!(
context,
Some(MessageContext::Offers(OffersContext::InvoiceRequest { .. }))
));
reply_path.unwrap()
},
Ok(PeeledOnion::Forward(_, _)) => panic!("Unexpected onion message forward"),
Err(e) => panic!("Failed to process onion message {:?}", e),
}
}

#[test]
#[cfg(async_payments)]
fn static_invoice_unknown_required_features() {
Expand Down Expand Up @@ -97,7 +74,7 @@ fn static_invoice_unknown_required_features() {
.onion_messenger
.next_onion_message_for_peer(nodes[1].node.get_our_node_id())
.unwrap();
let invreq_reply_path = extract_invoice_request_reply_path(&nodes[1], &invreq_om);
let invreq_reply_path = offers_tests::extract_invoice_request(&nodes[1], &invreq_om).1;
nodes[1]
.onion_messenger
.send_onion_message(
Expand Down Expand Up @@ -169,7 +146,7 @@ fn ignore_unexpected_static_invoice() {
.onion_messenger
.next_onion_message_for_peer(nodes[1].node.get_our_node_id())
.unwrap();
let invreq_reply_path = extract_invoice_request_reply_path(&nodes[1], &invreq_om);
let invreq_reply_path = offers_tests::extract_invoice_request(&nodes[1], &invreq_om).1;

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

nodes[1]
.onion_messenger
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/offers_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ fn extract_offer_nonce<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, message: &OnionMessa
}
}

fn extract_invoice_request<'a, 'b, 'c>(
pub(super) fn extract_invoice_request<'a, 'b, 'c>(
node: &Node<'a, 'b, 'c>, message: &OnionMessage
) -> (InvoiceRequest, BlindedMessagePath) {
match node.onion_messenger.peel_onion_message(message) {
Expand Down

0 comments on commit 8e37c78

Please sign in to comment.