Skip to content

Commit dba28b3

Browse files
committed
Introduce Blinded Payment Dummy Path test
1 parent 9184d9b commit dba28b3

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,56 @@ fn do_one_hop_blinded_path(success: bool) {
196196
}
197197
}
198198

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

0 commit comments

Comments
 (0)