Skip to content

Commit 186e812

Browse files
committed
Test sending, and receiving of user_custom_data
1 parent c2d5350 commit 186e812

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

lightning/src/ln/blinded_payment_tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ fn custom_tlvs_to_blinded_path() {
13791379
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
13801380
},
13811381
payment_context: PaymentContext::unknown(),
1382-
custom_data: Vec::new(),
1382+
custom_data: vec![43, 43]
13831383
};
13841384
let mut secp_ctx = Secp256k1::new();
13851385
let blinded_path = BlindedPaymentPath::new(
@@ -1393,6 +1393,7 @@ fn custom_tlvs_to_blinded_path() {
13931393
);
13941394

13951395
let recipient_onion_fields = RecipientOnionFields::spontaneous_empty()
1396+
.with_user_custom_data(vec![43, 43])
13961397
.with_sender_custom_tlvs(vec![((1 << 16) + 3, vec![42, 42])])
13971398
.unwrap();
13981399
nodes[0].node.send_payment(payment_hash, recipient_onion_fields.clone(),
@@ -1406,10 +1407,12 @@ fn custom_tlvs_to_blinded_path() {
14061407
let path = &[&nodes[1]];
14071408
let args = PassAlongPathArgs::new(&nodes[0], path, amt_msat, payment_hash, ev)
14081409
.with_payment_secret(payment_secret)
1410+
.with_user_custom_data(recipient_onion_fields.user_custom_data.clone())
14091411
.with_sender_custom_tlvs(recipient_onion_fields.sender_custom_tlvs.clone());
14101412
do_pass_along_path(args);
14111413
claim_payment_along_route(
14121414
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1]]], payment_preimage)
1415+
.with_user_custom_data(recipient_onion_fields.user_custom_data.clone())
14131416
.with_sender_custom_tlvs(recipient_onion_fields.sender_custom_tlvs.clone())
14141417
);
14151418
}

lightning/src/ln/functional_test_utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,6 +2887,10 @@ impl<'a, 'b, 'c, 'd> ClaimAlongRouteArgs<'a, 'b, 'c, 'd> {
28872887
self.allow_1_msat_fee_overpay = true;
28882888
self
28892889
}
2890+
pub fn with_user_custom_data(mut self, custom_tlvs: Vec<u8>) -> Self {
2891+
self.user_custom_data = custom_tlvs;
2892+
self
2893+
}
28902894
pub fn with_sender_custom_tlvs(mut self, custom_tlvs: Vec<(u64, Vec<u8>)>) -> Self {
28912895
self.sender_custom_tlvs = custom_tlvs;
28922896
self

lightning/src/ln/payment_tests.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3776,8 +3776,12 @@ fn test_retry_custom_tlvs() {
37763776
let mut route_params = route.route_params.clone().unwrap();
37773777

37783778
let sender_custom_tlvs = vec![((1 << 16) + 3, vec![0x42u8; 16])];
3779+
let user_custom_data = vec![0x43u8; 16];
37793780
let onion_fields = RecipientOnionFields::secret_only(payment_secret);
3780-
let onion_fields = onion_fields.with_sender_custom_tlvs(sender_custom_tlvs.clone()).unwrap();
3781+
let onion_fields = onion_fields
3782+
.with_user_custom_data(user_custom_data.clone())
3783+
.with_sender_custom_tlvs(sender_custom_tlvs.clone())
3784+
.unwrap();
37813785

37823786
nodes[0].router.expect_find_route(route_params.clone(), Ok(route.clone()));
37833787
nodes[0].node.send_payment(payment_hash, onion_fields,
@@ -3829,10 +3833,12 @@ fn test_retry_custom_tlvs() {
38293833
let path = &[&nodes[1], &nodes[2]];
38303834
let args = PassAlongPathArgs::new(&nodes[0], path, 1_000_000, payment_hash, events.pop().unwrap())
38313835
.with_payment_secret(payment_secret)
3836+
.with_user_custom_data(user_custom_data.clone())
38323837
.with_sender_custom_tlvs(sender_custom_tlvs.clone());
38333838
do_pass_along_path(args);
38343839
claim_payment_along_route(
38353840
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage)
3841+
.with_user_custom_data(user_custom_data)
38363842
.with_sender_custom_tlvs(sender_custom_tlvs)
38373843
);
38383844
}

0 commit comments

Comments
 (0)