Skip to content

Commit 2a0f78a

Browse files
committed
Introduce custom data test for message::ReceiveTlvs
1 parent 5b5e7ef commit 2a0f78a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lightning/src/ln/async_payments_tests.rs

+7
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,13 @@ fn ignore_unexpected_static_invoice() {
305305
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1_000_000, 0);
306306
create_unannounced_chan_between_nodes_with_value(&nodes, 1, 2, 1_000_000, 0);
307307

308+
let recipient_tlvs = ReceiveTlvs {
309+
context: Some(MessageContext::Offers(OffersContext::InvoiceRequest {
310+
nonce: Nonce([42; 16]),
311+
})),
312+
custom_data: None,
313+
};
314+
308315
// Initiate payment to the sender's intended offer.
309316
let (offer, valid_static_invoice) =
310317
create_static_invoice(&nodes[1], &nodes[2], None, &secp_ctx);

lightning/src/onion_message/functional_tests.rs

+18
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,24 @@ fn one_blinded_hop() {
438438
pass_along_path(&nodes);
439439
}
440440

441+
#[test]
442+
fn one_blinded_hop_with_custom_data() {
443+
let nodes = create_nodes(2);
444+
let test_msg = TestCustomMessage::Pong;
445+
446+
let secp_ctx = Secp256k1::new();
447+
let recipient_tlvs = ReceiveTlvs {
448+
context: Some(MessageContext::Custom(Vec::new())),
449+
custom_data: Some(vec![42; 42]),
450+
};
451+
let blinded_path = BlindedMessagePath::new(&[], nodes[1].node_id, recipient_tlvs, &*nodes[1].entropy_source, &secp_ctx).unwrap();
452+
let destination = Destination::BlindedPath(blinded_path);
453+
let instructions = MessageSendInstructions::WithoutReplyPath { destination };
454+
nodes[0].messenger.send_onion_message(test_msg, instructions).unwrap();
455+
nodes[1].custom_message_handler.expect_message_with_custom_data(TestCustomMessage::Pong, vec![42; 42]);
456+
pass_along_path(&nodes);
457+
}
458+
441459
#[test]
442460
fn two_unblinded_two_blinded() {
443461
let nodes = create_nodes(5);

0 commit comments

Comments
 (0)