+struct TestMessageRouter {}
+
+impl MessageRouter for TestMessageRouter {
+ fn find_path(
+ &self, _sender: PublicKey, _peers: Vec<PublicKey>, destination: Destination
+ ) -> Result<OnionMessagePath, ()> {
+ Ok(OnionMessagePath {
+ intermediate_nodes: vec![],
+ destination,
+ first_node_addresses: None,
+ })
+ }
+
+ fn create_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
+ &self, _recipient: PublicKey, _peers: Vec<PublicKey>, _secp_ctx: &Secp256k1<T>,
+ ) -> Result<Vec<BlindedPath>, ()> {
+ unreachable!()
+ }
+}
+
+struct TestOffersMessageHandler {}
+
+impl OffersMessageHandler for TestOffersMessageHandler {
+ fn handle_message(&self, _message: OffersMessage, _responder: Option<Responder>) -> ResponseInstruction<OffersMessage> {
+ ResponseInstruction::NoResponse
+ }
+}
+
+#[derive(Debug)]
+struct TestCustomMessage {}
+
+const CUSTOM_MESSAGE_TYPE: u64 = 4242;
+const CUSTOM_MESSAGE_CONTENTS: [u8; 32] = [42; 32];
+
+impl OnionMessageContents for TestCustomMessage {
+ fn tlv_type(&self) -> u64 {
+ CUSTOM_MESSAGE_TYPE
+ }
+ fn msg_type(&self) -> &'static str {
+ "Custom Message"
+ }
+}
+
+impl Writeable for TestCustomMessage {
+ fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
+ Ok(CUSTOM_MESSAGE_CONTENTS.write(w)?)
+ }
+}
+
+struct TestCustomMessageHandler {}
+
+impl CustomOnionMessageHandler for TestCustomMessageHandler {
+ type CustomMessage = TestCustomMessage;
+ fn handle_custom_message(&self, message: Self::CustomMessage, responder: Option<Responder>) -> ResponseInstruction<Self::CustomMessage> {
+ match responder {
+ Some(responder) => responder.respond(message),
+ None => ResponseInstruction::NoResponse
+ }
+ }
+ fn read_custom_message<R: io::Read>(&self, _message_type: u64, buffer: &mut R) -> Result<Option<Self::CustomMessage>, msgs::DecodeError> {
+ let mut buf = Vec::new();
+ buffer.read_to_end(&mut buf)?;
+ return Ok(Some(TestCustomMessage {}))
+ }
+ fn release_pending_custom_messages(&self) -> Vec<PendingOnionMessage<Self::CustomMessage>> {
+ vec![]
+ }
+}
+