Skip to content

Commit 1b80dfa

Browse files
committed
Test sending, and receiving of user_custom_data
1 parent 95e7559 commit 1b80dfa

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
@@ -1363,7 +1363,7 @@ fn invalid_keysend_payment_secret() {
13631363
}
13641364

13651365
#[test]
1366-
fn sender_custom_tlvs_to_blinded_path() {
1366+
fn custom_tlvs_to_blinded_path() {
13671367
let chanmon_cfgs = create_chanmon_cfgs(2);
13681368
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
13691369
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
@@ -1379,7 +1379,7 @@ fn sender_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 sender_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) + 1, vec![42, 42])])
13971398
.unwrap();
13981399
nodes[0].node.send_payment(payment_hash, recipient_onion_fields.clone(),
@@ -1406,10 +1407,12 @@ fn sender_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

+4
Original file line numberDiff line numberDiff line change
@@ -2671,6 +2671,10 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
26712671
self.expected_preimage = Some(payment_preimage);
26722672
self
26732673
}
2674+
pub fn with_user_custom_data(mut self, custom_tlvs: Vec<u8>) -> Self {
2675+
self.user_custom_data = custom_tlvs;
2676+
self
2677+
}
26742678
pub fn with_sender_custom_tlvs(mut self, sender_custom_tlvs: Vec<(u64, Vec<u8>)>) -> Self {
26752679
self.sender_custom_tlvs = sender_custom_tlvs;
26762680
self

lightning/src/ln/payment_tests.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -3754,7 +3754,7 @@ fn do_test_sender_custom_tlvs(spontaneous: bool, even_tlvs: bool, known_tlvs: bo
37543754
}
37553755

37563756
#[test]
3757-
fn test_retry_sender_custom_tlvs() {
3757+
fn test_retry_custom_tlvs() {
37583758
// Test that sender custom TLVs are successfully sent on retries
37593759
let chanmon_cfgs = create_chanmon_cfgs(3);
37603760
let node_cfgs = create_node_cfgs(3, &chanmon_cfgs);
@@ -3776,8 +3776,9 @@ fn test_retry_sender_custom_tlvs() {
37763776
let mut route_params = route.route_params.clone().unwrap();
37773777

37783778
let sender_custom_tlvs = vec![((1 << 16) + 1, 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.with_user_custom_data(user_custom_data.clone()).with_sender_custom_tlvs(sender_custom_tlvs.clone()).unwrap();
37813782

37823783
nodes[0].router.expect_find_route(route_params.clone(), Ok(route.clone()));
37833784
nodes[0].node.send_payment(payment_hash, onion_fields,
@@ -3829,10 +3830,12 @@ fn test_retry_sender_custom_tlvs() {
38293830
let path = &[&nodes[1], &nodes[2]];
38303831
let args = PassAlongPathArgs::new(&nodes[0], path, 1_000_000, payment_hash, events.pop().unwrap())
38313832
.with_payment_secret(payment_secret)
3833+
.with_user_custom_data(user_custom_data.clone())
38323834
.with_sender_custom_tlvs(sender_custom_tlvs.clone());
38333835
do_pass_along_path(args);
38343836
claim_payment_along_route(
38353837
ClaimAlongRouteArgs::new(&nodes[0], &[&[&nodes[1], &nodes[2]]], payment_preimage)
3838+
.with_user_custom_data(user_custom_data.clone())
38363839
.with_sender_custom_tlvs(sender_custom_tlvs)
38373840
);
38383841
}

0 commit comments

Comments
 (0)