Skip to content

Commit ee51aed

Browse files
committed
Introduce Tests for Offers and Refunds Without Blinded Paths
1 parent 6e0c973 commit ee51aed

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

lightning/src/ln/offers_tests.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,57 @@ fn extract_invoice_error<'a, 'b, 'c>(
254254
}
255255
}
256256

257+
/// Checks that an offer can be created with no blinded paths.
258+
#[test]
259+
fn create_offer_with_no_blinded_path() {
260+
let chanmon_cfgs = create_chanmon_cfgs(2);
261+
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
262+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
263+
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
264+
265+
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 1_000_000_000);
266+
267+
let alice = &nodes[0];
268+
let alice_id = alice.node.get_our_node_id();
269+
270+
let router = DefaultMessageRouter::new(alice.network_graph, alice.node.entropy_source)
271+
.with_no_blinded_path();
272+
let offer = alice.offers_handler
273+
.create_offer_builder(router).unwrap()
274+
.amount_msats(10_000_000)
275+
.build().unwrap();
276+
assert_eq!(offer.issuer_signing_pubkey(), Some(alice_id));
277+
assert!(offer.paths().is_empty());
278+
}
279+
280+
/// Checks that a refund can be created with no blinded paths.
281+
#[test]
282+
fn create_refund_with_no_blinded_path() {
283+
let chanmon_cfgs = create_chanmon_cfgs(2);
284+
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
285+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
286+
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
287+
288+
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 1_000_000_000);
289+
290+
let alice = &nodes[0];
291+
let alice_id = alice.node.get_our_node_id();
292+
293+
let absolute_expiry = Duration::from_secs(u64::MAX);
294+
let payment_id = PaymentId([1; 32]);
295+
296+
let router = DefaultMessageRouter::new(alice.network_graph, alice.node.entropy_source)
297+
.with_no_blinded_path();
298+
let refund = alice.offers_handler
299+
.create_refund_builder(router, 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
300+
.unwrap()
301+
.build().unwrap();
302+
assert_eq!(refund.amount_msats(), 10_000_000);
303+
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
304+
assert_eq!(refund.payer_signing_pubkey(), alice_id);
305+
assert!(refund.paths().is_empty());
306+
}
307+
257308
/// Checks that blinded paths without Tor-only nodes are preferred when constructing an offer.
258309
#[test]
259310
fn prefers_non_tor_nodes_in_blinded_paths() {

0 commit comments

Comments
 (0)