Skip to content

Commit d6dde1e

Browse files
committed
Introduce Tests for Offers and Refunds Without Blinded Paths
1 parent 6574335 commit d6dde1e

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
@@ -255,6 +255,53 @@ fn extract_invoice_error<'a, 'b, 'c>(
255255
}
256256
}
257257

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

0 commit comments

Comments
 (0)