Skip to content

Commit

Permalink
Expand the return type of handle_onion_message_response.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shaavan committed May 11, 2024
1 parent 93c2e40 commit 8d5f9dc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lightning/src/onion_message/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::routing::test_utils::{add_channel, add_or_update_node};
use crate::sign::{NodeSigner, Recipient};
use crate::util::ser::{FixedLengthReader, LengthReadable, Writeable, Writer};
use crate::util::test_utils;
use super::messenger::{CustomOnionMessageHandler, DefaultMessageRouter, Destination, OnionMessagePath, OnionMessenger, PendingOnionMessage, Responder, ResponseInstruction, SendError};
use super::messenger::{CustomOnionMessageHandler, DefaultMessageRouter, Destination, OnionMessagePath, OnionMessenger, PendingOnionMessage, Responder, ResponseInstruction, SendError, SendSuccess};
use super::offers::{OffersMessage, OffersMessageHandler};
use super::packet::{OnionMessageContents, Packet};

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

// 6. Simulate Alice asynchronously responding back to Bob with a response.
nodes[0].messenger.handle_onion_message_response(response_instruction);
assert_eq!(
nodes[0].messenger.handle_onion_message_response(response_instruction),
Ok(Some(SendSuccess::Buffered)),
);

bob.custom_message_handler.expect_message(TestCustomMessage::Response);

pass_along_path(&nodes);
Expand Down

0 comments on commit 8d5f9dc

Please sign in to comment.