Skip to content

Commit 01b78f0

Browse files
committed
Test sending and receiving of user_custom_data
1 parent d37bb5f commit 01b78f0

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lightning/src/ln/blinded_payment_tests.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ fn conditionally_round_fwd_amt() {
12291229

12301230

12311231
#[test]
1232-
fn sender_custom_tlvs_to_blinded_path() {
1232+
fn custom_tlvs_to_blinded_path() {
12331233
let chanmon_cfgs = create_chanmon_cfgs(2);
12341234
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
12351235
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
@@ -1245,7 +1245,7 @@ fn sender_custom_tlvs_to_blinded_path() {
12451245
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
12461246
},
12471247
payment_context: PaymentContext::Bolt12Refund(Bolt12RefundContext {}),
1248-
custom_data: Vec::new(),
1248+
custom_data: vec![43, 43],
12491249
};
12501250
let nonce = Nonce([42u8; 16]);
12511251
let expanded_key = chanmon_cfgs[1].keys_manager.get_inbound_payment_key();
@@ -1262,6 +1262,7 @@ fn sender_custom_tlvs_to_blinded_path() {
12621262
);
12631263

12641264
let recipient_onion_fields = RecipientOnionFields::spontaneous_empty()
1265+
.with_user_custom_data(vec![43, 43])
12651266
.with_sender_custom_tlvs(vec![((1 << 16) + 1, vec![42, 42])])
12661267
.unwrap();
12671268
nodes[0].node.send_payment(payment_hash, recipient_onion_fields.clone(),
@@ -1274,11 +1275,13 @@ fn sender_custom_tlvs_to_blinded_path() {
12741275

12751276
let path = &[&nodes[1]];
12761277
let args = PassAlongPathArgs::new(&nodes[0], path, amt_msat, payment_hash, ev)
1278+
.with_user_custom_data(recipient_onion_fields.user_custom_data.clone())
12771279
.with_payment_secret(payment_secret)
12781280
.with_sender_custom_tlvs(recipient_onion_fields.sender_custom_tlvs.clone());
12791281
do_pass_along_path(args);
12801282
claim_payment_along_route(
12811283
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1]]], payment_preimage)
1284+
.with_user_custom_data(recipient_onion_fields.user_custom_data.clone())
12821285
.with_sender_custom_tlvs(recipient_onion_fields.sender_custom_tlvs.clone())
12831286
);
12841287
}

lightning/src/ln/functional_test_utils.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2683,6 +2683,10 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
26832683
self.expected_preimage = Some(payment_preimage);
26842684
self
26852685
}
2686+
pub fn with_user_custom_data(mut self, custom_tlvs: Vec<u8>) -> Self {
2687+
self.user_custom_data = custom_tlvs;
2688+
self
2689+
}
26862690
pub fn with_sender_custom_tlvs(mut self, sender_custom_tlvs: Vec<(u64, Vec<u8>)>) -> Self {
26872691
self.sender_custom_tlvs = sender_custom_tlvs;
26882692
self

lightning/src/ln/payment_tests.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -3746,7 +3746,7 @@ fn do_test_sender_custom_tlvs(spontaneous: bool, even_tlvs: bool, known_tlvs: bo
37463746
}
37473747

37483748
#[test]
3749-
fn test_retry_sender_custom_tlvs() {
3749+
fn test_retry_custom_tlvs() {
37503750
// Test that sender custom TLVs are successfully sent on retries
37513751
let chanmon_cfgs = create_chanmon_cfgs(3);
37523752
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
@@ -3768,8 +3768,9 @@ fn test_retry_sender_custom_tlvs() {
37683768
let mut route_params = route.route_params.clone().unwrap();
37693769

37703770
let sender_custom_tlvs = vec![((1 << 16) + 1, vec![0x42u8; 16])];
3771+
let user_custom_data = vec![0x43u8; 16];
37713772
let onion_fields = RecipientOnionFields::secret_only(payment_secret);
3772-
let onion_fields = onion_fields.with_sender_custom_tlvs(sender_custom_tlvs.clone()).unwrap();
3773+
let onion_fields = onion_fields.with_user_custom_data(user_custom_data.clone()).with_sender_custom_tlvs(sender_custom_tlvs.clone()).unwrap();
37733774

37743775
nodes[0].router.expect_find_route(route_params.clone(), Ok(route.clone()));
37753776
nodes[0].node.send_payment(payment_hash, onion_fields,
@@ -3821,10 +3822,12 @@ fn test_retry_sender_custom_tlvs() {
38213822
let path = &[&nodes[1], &nodes[2]];
38223823
let args = PassAlongPathArgs::new(&nodes[0], path, 1_000_000, payment_hash, events.pop().unwrap())
38233824
.with_payment_secret(payment_secret)
3825+
.with_user_custom_data(user_custom_data.clone())
38243826
.with_sender_custom_tlvs(sender_custom_tlvs.clone());
38253827
do_pass_along_path(args);
38263828
claim_payment_along_route(
38273829
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage)
3830+
.with_user_custom_data(user_custom_data.clone())
38283831
.with_sender_custom_tlvs(sender_custom_tlvs)
38293832
);
38303833
}

0 commit comments

Comments
 (0)