Skip to content

Commit 25dc56e

Browse files
committed
Introduce Blinded Payment Dummy Path test
1 parent 38bcda3 commit 25dc56e

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,58 @@ fn do_one_hop_blinded_path(success: bool) {
192192
}
193193
}
194194

195+
#[test]
196+
fn one_hop_blinded_path_with_dummy_hops() {
197+
let chanmon_cfgs = create_chanmon_cfgs(2);
198+
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
199+
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
200+
let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
201+
let chan_upd = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0).0.contents;
202+
203+
let amt_msat = 5000;
204+
let (payment_preimage, payment_hash, payment_secret) = get_payment_preimage_hash(&nodes[1], Some(amt_msat), None);
205+
let payee_tlvs = ReceiveTlvs {
206+
payment_secret,
207+
payment_constraints: PaymentConstraints {
208+
max_cltv_expiry: u32::max_value(),
209+
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
210+
},
211+
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {}),
212+
};
213+
let receive_auth_key = chanmon_cfgs[1].keys_manager.get_receive_auth_key();
214+
215+
let mut secp_ctx = Secp256k1::new();
216+
let blinded_path = BlindedPaymentPath::new_with_dummy_hops(
217+
&[], nodes[1].node.get_our_node_id(), 1, receive_auth_key,
218+
payee_tlvs, u64::MAX, TEST_FINAL_CLTV as u16,
219+
&chanmon_cfgs[1].keys_manager, &secp_ctx
220+
).unwrap();
221+
222+
let route_params = RouteParameters::from_payment_params_and_value(
223+
PaymentParameters::blinded(vec![blinded_path]),
224+
amt_msat,
225+
);
226+
nodes[0].node.send_payment(payment_hash, RecipientOnionFields::spontaneous_empty(),
227+
PaymentId(payment_hash.0), route_params, Retry::Attempts(0)).unwrap();
228+
check_added_monitors(&nodes[0], 1);
229+
230+
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
231+
assert_eq!(events.len(), 1);
232+
let ev = remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut events);
233+
pass_along_path_with_dummy(
234+
&nodes[0],
235+
&[&nodes[1]],
236+
Some(1),
237+
amt_msat,
238+
payment_hash,
239+
Some(payment_secret),
240+
ev,
241+
true,
242+
None,
243+
);
244+
claim_payment(&nodes[0], &[&nodes[1]], payment_preimage);
245+
}
246+
195247
#[test]
196248
fn mpp_to_one_hop_blinded_path() {
197249
let chanmon_cfgs = create_chanmon_cfgs(4);

0 commit comments

Comments
 (0)