Skip to content

Commit e67b695

Browse files
committed
Test: Add coverage for Offers and Refunds without blinded paths
Introduced tests to validate the behavior of Offers and Refunds created without blinded paths, using `NullMessageRouter`.
1 parent f13ec37 commit e67b695

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

lightning/src/ln/offers_tests.rs

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use crate::offers::invoice_error::InvoiceError;
5858
use crate::offers::invoice_request::{InvoiceRequest, InvoiceRequestFields};
5959
use crate::offers::nonce::Nonce;
6060
use crate::offers::parse::Bolt12SemanticError;
61-
use crate::onion_message::messenger::{Destination, MessageSendInstructions, PeeledOnion};
61+
use crate::onion_message::messenger::{Destination, MessageSendInstructions, NullMessageRouter, PeeledOnion};
6262
use crate::onion_message::offers::OffersMessage;
6363
use crate::onion_message::packet::ParsedOnionMessageContents;
6464
use crate::routing::gossip::{NodeAlias, NodeId};
@@ -265,6 +265,55 @@ fn extract_invoice_error<'a, 'b, 'c>(
265265
}
266266
}
267267

268+
/// Checks that an offer can be created with no blinded paths.
269+
#[test]
270+
fn create_offer_with_no_blinded_path() {
271+
let chanmon_cfgs = create_chanmon_cfgs(2);
272+
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
273+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
274+
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
275+
276+
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 1_000_000_000);
277+
278+
let alice = &nodes[0];
279+
let alice_id = alice.node.get_our_node_id();
280+
281+
let router = NullMessageRouter {};
282+
let offer = alice.node
283+
.create_offer_builder_using_router(router).unwrap()
284+
.amount_msats(10_000_000)
285+
.build().unwrap();
286+
assert_eq!(offer.issuer_signing_pubkey(), Some(alice_id));
287+
assert!(offer.paths().is_empty());
288+
}
289+
290+
/// Checks that a refund can be created with no blinded paths.
291+
#[test]
292+
fn create_refund_with_no_blinded_path() {
293+
let chanmon_cfgs = create_chanmon_cfgs(2);
294+
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
295+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
296+
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
297+
298+
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 1_000_000_000);
299+
300+
let alice = &nodes[0];
301+
let alice_id = alice.node.get_our_node_id();
302+
303+
let absolute_expiry = Duration::from_secs(u64::MAX);
304+
let payment_id = PaymentId([1; 32]);
305+
306+
let router = NullMessageRouter {};
307+
let refund = alice.node
308+
.create_refund_builder_using_router(router, 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), RouteParametersConfig::default())
309+
.unwrap()
310+
.build().unwrap();
311+
assert_eq!(refund.amount_msats(), 10_000_000);
312+
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
313+
assert_eq!(refund.payer_signing_pubkey(), alice_id);
314+
assert!(refund.paths().is_empty());
315+
}
316+
268317
/// Checks that blinded paths without Tor-only nodes are preferred when constructing an offer.
269318
#[test]
270319
fn prefers_non_tor_nodes_in_blinded_paths() {

0 commit comments

Comments
 (0)