|
8 | 8 | // licenses. |
9 | 9 |
|
10 | 10 | use crate::blinded_path::payment::{ |
11 | | - BlindedPaymentPath, Bolt12RefundContext, ForwardTlvs, PaymentConstraints, PaymentContext, |
12 | | - PaymentForwardNode, PaymentRelay, ReceiveTlvs, PAYMENT_PADDING_ROUND_OFF, |
| 11 | + BlindedPaymentPath, Bolt12RefundContext, DummyTlvs, ForwardTlvs, PaymentConstraints, |
| 12 | + PaymentContext, PaymentForwardNode, PaymentRelay, ReceiveTlvs, PAYMENT_PADDING_ROUND_OFF, |
13 | 13 | }; |
14 | 14 | use crate::blinded_path::utils::is_padded; |
15 | 15 | use crate::blinded_path::{self, BlindedHop}; |
@@ -196,6 +196,72 @@ fn do_one_hop_blinded_path(success: bool) { |
196 | 196 | } |
197 | 197 | } |
198 | 198 |
|
| 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 = |
| 206 | + create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0).0.contents; |
| 207 | + |
| 208 | + let amt_msat = 5000; |
| 209 | + let (payment_preimage, payment_hash, payment_secret) = |
| 210 | + get_payment_preimage_hash(&nodes[1], Some(amt_msat), None); |
| 211 | + let payee_tlvs = ReceiveTlvs { |
| 212 | + payment_secret, |
| 213 | + payment_constraints: PaymentConstraints { |
| 214 | + max_cltv_expiry: u32::max_value(), |
| 215 | + htlc_minimum_msat: chan_upd.htlc_minimum_msat, |
| 216 | + }, |
| 217 | + payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {}), |
| 218 | + }; |
| 219 | + let receive_auth_key = chanmon_cfgs[1].keys_manager.get_receive_auth_key(); |
| 220 | + let dummy_tlvs = [DummyTlvs::default(); 2]; |
| 221 | + |
| 222 | + let mut secp_ctx = Secp256k1::new(); |
| 223 | + let blinded_path = BlindedPaymentPath::new_with_dummy_hops( |
| 224 | + &[], |
| 225 | + nodes[1].node.get_our_node_id(), |
| 226 | + &dummy_tlvs, |
| 227 | + receive_auth_key, |
| 228 | + payee_tlvs, |
| 229 | + u64::MAX, |
| 230 | + TEST_FINAL_CLTV as u16, |
| 231 | + &chanmon_cfgs[1].keys_manager, |
| 232 | + &secp_ctx, |
| 233 | + ) |
| 234 | + .unwrap(); |
| 235 | + |
| 236 | + let route_params = RouteParameters::from_payment_params_and_value( |
| 237 | + PaymentParameters::blinded(vec![blinded_path]), |
| 238 | + amt_msat, |
| 239 | + ); |
| 240 | + nodes[0] |
| 241 | + .node |
| 242 | + .send_payment( |
| 243 | + payment_hash, |
| 244 | + RecipientOnionFields::spontaneous_empty(), |
| 245 | + PaymentId(payment_hash.0), |
| 246 | + route_params, |
| 247 | + Retry::Attempts(0), |
| 248 | + ) |
| 249 | + .unwrap(); |
| 250 | + check_added_monitors(&nodes[0], 1); |
| 251 | + |
| 252 | + let mut events = nodes[0].node.get_and_clear_pending_msg_events(); |
| 253 | + assert_eq!(events.len(), 1); |
| 254 | + let ev = remove_first_msg_event_to_node(&nodes[1].node.get_our_node_id(), &mut events); |
| 255 | + |
| 256 | + let path = &[&nodes[1]]; |
| 257 | + let args = PassAlongPathArgs::new(&nodes[0], path, amt_msat, payment_hash, ev) |
| 258 | + .with_dummy_tlvs(&dummy_tlvs) |
| 259 | + .with_payment_secret(payment_secret); |
| 260 | + |
| 261 | + do_pass_along_path(args); |
| 262 | + claim_payment(&nodes[0], &[&nodes[1]], payment_preimage); |
| 263 | +} |
| 264 | + |
199 | 265 | #[test] |
200 | 266 | #[rustfmt::skip] |
201 | 267 | fn mpp_to_one_hop_blinded_path() { |
|
0 commit comments