+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,
+ })
+ }
+}
+
+struct TestOffersMessageHandler {}
+
+impl OffersMessageHandler for TestOffersMessageHandler {
+ fn handle_message(&self, _message: OffersMessage) -> Option<OffersMessage> {
+ None
+ }
+}
+
+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
+ }
+}
+
+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, _msg: Self::CustomMessage) -> Option<Self::CustomMessage> {
+ Some(TestCustomMessage {})
+ }
+ 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![]
+ }
+}
+