Skip to content

Commit 7a18051

Browse files
committed
Introduce tests for Offer and Refund with no Blinded Path
1 parent 18f18ef commit 7a18051

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

lightning/src/ln/offers_tests.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,53 @@ fn prefers_more_connected_nodes_in_blinded_paths() {
382382
}
383383
}
384384

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

0 commit comments

Comments
 (0)