Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow responding asynchronously to OnionMessage #2996

Merged
merged 5 commits into from
May 31, 2024

Commits on May 30, 2024

  1. Convert handle_onion_message_response to a public function and add te…

    …st coverage
    
    This commit modifies handle_onion_message_response to be accessible
    publicly as handle_onion_message, enabling users to respond
    asynchronously. Additionally, a new test is introduced to validate this
    functionality.
    shaavan committed May 30, 2024
    Configuration menu
    Copy the full SHA
    ca5b6b5 View commit details
    Browse the repository at this point in the history
  2. Introduce ResponseInstruction::WithReplyPath variant.

    And expand handle_onion_message_response return Type
    
    1. Introduce a new function in OnionMessenger to create blinded paths.
    2. Use it in handle_onion_message_response to create a reply_path for
       the right variant and use it in onion_message.
    3. Expand the return type of handle_onion_message_response 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.
    shaavan committed May 30, 2024
    Configuration menu
    Copy the full SHA
    6904786 View commit details
    Browse the repository at this point in the history
  3. Refactor: Rename Request & Response to Ping & Pong

    1. These two variants will be modified in an upcoming commit
       to be each other's response.
    2. The names are updated to better fit their new roles.
    shaavan committed May 30, 2024
    Configuration menu
    Copy the full SHA
    7d5dd6b View commit details
    Browse the repository at this point in the history
  4. Refactor TestCustomMessageHandler

    - Introduce a new struct for keeping expectations organized.
    - Add a boolean field to track whether a response is expected,
      and hence whether a `reply_path` should be included with the response.
    - Update Ping and Pong roles for bidirectional communication.
    - Introduce panic for when there is no responder and we were expecting
      to include a `reply_path`.
    - Refactor `handle_custom_message` code.
    shaavan committed May 30, 2024
    Configuration menu
    Copy the full SHA
    b95cfed View commit details
    Browse the repository at this point in the history
  5. Introduce new tests for ResponseInstruction::WithReplyPath

    - The new tests check both successful and unsuccessful `reply_path`
      creation conditions.
    shaavan committed May 30, 2024
    Configuration menu
    Copy the full SHA
    d8adbb0 View commit details
    Browse the repository at this point in the history