Skip to content

Commit 79d6fdd

Browse files
committed
Introduce tests for Offer and Refund with no Blinded Path
1 parent 8263e41 commit 79d6fdd

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

lightning/src/ln/offers_tests.rs

+47
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,53 @@ fn prefers_more_connected_nodes_in_blinded_paths() {
391391
}
392392
}
393393

394+
/// Checks that an offer can be created with no blinded paths.
395+
#[test]
396+
fn create_offer_with_no_blinded_path() {
397+
let chanmon_cfgs = create_chanmon_cfgs(2);
398+
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
399+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
400+
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
401+
402+
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 1_000_000_000);
403+
404+
let alice = &nodes[0];
405+
let alice_id = alice.node.get_our_node_id();
406+
407+
let offer = alice.node
408+
.create_offer_builder(None).unwrap()
409+
.amount_msats(10_000_000)
410+
.build().unwrap();
411+
assert_eq!(offer.signing_pubkey(), Some(alice_id));
412+
assert!(offer.paths().is_empty());
413+
}
414+
415+
/// Checks that a refund can be created with no blinded paths.
416+
#[test]
417+
fn create_refund_with_no_blinded_path() {
418+
let chanmon_cfgs = create_chanmon_cfgs(2);
419+
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
420+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
421+
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
422+
423+
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 10_000_000, 1_000_000_000);
424+
425+
let alice = &nodes[0];
426+
let alice_id = alice.node.get_our_node_id();
427+
428+
let absolute_expiry = Duration::from_secs(u64::MAX);
429+
let payment_id = PaymentId([1; 32]);
430+
431+
let refund = alice.node
432+
.create_refund_builder(None, 10_000_000, absolute_expiry, payment_id, Retry::Attempts(0), None)
433+
.unwrap()
434+
.build().unwrap();
435+
assert_eq!(refund.amount_msats(), 10_000_000);
436+
assert_eq!(refund.absolute_expiry(), Some(absolute_expiry));
437+
assert_eq!(refund.payer_id(), alice_id);
438+
assert!(refund.paths().is_empty());
439+
}
440+
394441
/// Checks that blinded paths are compact for short-lived offers.
395442
#[test]
396443
fn creates_short_lived_offer() {

0 commit comments

Comments
 (0)