Skip to content

Commit 8d5f9dc

Browse files
committed
Expand the return type of handle_onion_message_response.
The return type is expanded to handle three cases: 1. Ok(None) in case of no response to be sent. 2. Ok(Some(SendSuccess) and Err(SendError) in case of successful and unsuccessful queueing up of response messages respectively. This allows the user to get access to the Success/Failure status of the sending of response and handle it accordingly.
1 parent 93c2e40 commit 8d5f9dc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lightning/src/onion_message/functional_tests.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::routing::test_utils::{add_channel, add_or_update_node};
1818
use crate::sign::{NodeSigner, Recipient};
1919
use crate::util::ser::{FixedLengthReader, LengthReadable, Writeable, Writer};
2020
use crate::util::test_utils;
21-
use super::messenger::{CustomOnionMessageHandler, DefaultMessageRouter, Destination, OnionMessagePath, OnionMessenger, PendingOnionMessage, Responder, ResponseInstruction, SendError};
21+
use super::messenger::{CustomOnionMessageHandler, DefaultMessageRouter, Destination, OnionMessagePath, OnionMessenger, PendingOnionMessage, Responder, ResponseInstruction, SendError, SendSuccess};
2222
use super::offers::{OffersMessage, OffersMessageHandler};
2323
use super::packet::{OnionMessageContents, Packet};
2424

@@ -351,7 +351,11 @@ fn async_response_over_one_blinded_hop() {
351351
let response_instruction = nodes[0].custom_message_handler.handle_custom_message(message, responder);
352352

353353
// 6. Simulate Alice asynchronously responding back to Bob with a response.
354-
nodes[0].messenger.handle_onion_message_response(response_instruction);
354+
assert_eq!(
355+
nodes[0].messenger.handle_onion_message_response(response_instruction),
356+
Ok(Some(SendSuccess::Buffered)),
357+
);
358+
355359
bob.custom_message_handler.expect_message(TestCustomMessage::Response);
356360

357361
pass_along_path(&nodes);

0 commit comments

Comments
 (0)