Skip to content

Commit ebcc448

Browse files
committed
Test sending, and receiving of user_custom_data
1 parent abb7acb commit ebcc448

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

lightning/src/ln/blinded_payment_tests.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ fn custom_tlvs_to_blinded_path() {
13851385
htlc_minimum_msat: chan_upd.htlc_minimum_msat,
13861386
},
13871387
payment_context: PaymentContext::unknown(),
1388-
custom_data: Vec::new(),
1388+
custom_data: vec![43, 43]
13891389
};
13901390
let mut secp_ctx = Secp256k1::new();
13911391
let blinded_path = BlindedPaymentPath::new(
@@ -1399,6 +1399,7 @@ fn custom_tlvs_to_blinded_path() {
13991399
);
14001400

14011401
let recipient_onion_fields = RecipientOnionFields::spontaneous_empty()
1402+
.with_user_custom_data(vec![43, 43])
14021403
.with_sender_custom_tlvs(vec![((1 << 16) + 3, vec![42, 42])])
14031404
.unwrap();
14041405
nodes[0].node.send_payment(payment_hash, recipient_onion_fields.clone(),
@@ -1412,10 +1413,12 @@ fn custom_tlvs_to_blinded_path() {
14121413
let path = &[&nodes[1]];
14131414
let args = PassAlongPathArgs::new(&nodes[0], path, amt_msat, payment_hash, ev)
14141415
.with_payment_secret(payment_secret)
1416+
.with_user_custom_data(recipient_onion_fields.user_custom_data.clone())
14151417
.with_sender_custom_tlvs(recipient_onion_fields.sender_custom_tlvs.clone());
14161418
do_pass_along_path(args);
14171419
claim_payment_along_route(
14181420
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1]]], payment_preimage)
1421+
.with_user_custom_data(recipient_onion_fields.user_custom_data.clone())
14191422
.with_sender_custom_tlvs(recipient_onion_fields.sender_custom_tlvs.clone())
14201423
);
14211424
}

lightning/src/ln/functional_test_utils.rs

+4
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

+7-1
Original file line numberDiff line numberDiff line change
@@ -3783,8 +3783,12 @@ fn test_retry_custom_tlvs() {
37833783
let mut route_params = route.route_params.clone().unwrap();
37843784

37853785
let sender_custom_tlvs = vec![((1 << 16) + 3, vec![0x42u8; 16])];
3786+
let user_custom_data = vec![0x43u8; 16];
37863787
let onion_fields = RecipientOnionFields::secret_only(payment_secret);
3787-
let onion_fields = onion_fields.with_sender_custom_tlvs(sender_custom_tlvs.clone()).unwrap();
3788+
let onion_fields = onion_fields
3789+
.with_user_custom_data(user_custom_data.clone())
3790+
.with_sender_custom_tlvs(sender_custom_tlvs.clone())
3791+
.unwrap();
37883792

37893793
nodes[0].router.expect_find_route(route_params.clone(), Ok(route.clone()));
37903794
nodes[0].node.send_payment(payment_hash, onion_fields,
@@ -3836,10 +3840,12 @@ fn test_retry_custom_tlvs() {
38363840
let path = &[&nodes[1], &nodes[2]];
38373841
let args = PassAlongPathArgs::new(&nodes[0], path, 1_000_000, payment_hash, events.pop().unwrap())
38383842
.with_payment_secret(payment_secret)
3843+
.with_user_custom_data(user_custom_data.clone())
38393844
.with_sender_custom_tlvs(sender_custom_tlvs.clone());
38403845
do_pass_along_path(args);
38413846
claim_payment_along_route(
38423847
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage)
3848+
.with_user_custom_data(user_custom_data)
38433849
.with_sender_custom_tlvs(sender_custom_tlvs)
38443850
);
38453851
}

0 commit comments

Comments
 (0)