From 98a926f07d32924fa118e711a43d129261390ea2 Mon Sep 17 00:00:00 2001 From: Arik Sosman Date: Wed, 17 Apr 2024 23:16:11 -0700 Subject: [PATCH] Test Trampoline onion (de)serialization round trip. --- lightning/src/ln/msgs.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 9af5ec527..3d6f9d3fe 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -3200,7 +3200,7 @@ mod tests { use crate::ln::msgs::{self, FinalOnionHopData, OnionErrorPacket, CommonOpenChannelFields, CommonAcceptChannelFields, TrampolineOnionPacket}; use crate::ln::msgs::SocketAddress; use crate::routing::gossip::{NodeAlias, NodeId}; - use crate::util::ser::{BigSize, Hostname, Readable, ReadableArgs, TransactionU16LenLimited, Writeable}; + use crate::util::ser::{BigSize, FixedLengthReader, Hostname, LengthReadable, Readable, ReadableArgs, TransactionU16LenLimited, Writeable}; use crate::util::test_utils; use bitcoin::hashes::hex::FromHex; @@ -4516,6 +4516,13 @@ mod tests { let encoded_trampoline_packet = trampoline_packet.encode(); assert_eq!(encoded_trampoline_packet.len(), 716); + { // verify that a codec round trip works + let mut reader = Cursor::new(&encoded_trampoline_packet); + let mut trampoline_packet_reader = FixedLengthReader::new(&mut reader, encoded_trampoline_packet.len() as u64); + let decoded_trampoline_packet: TrampolineOnionPacket = ::read(&mut trampoline_packet_reader).unwrap(); + assert_eq!(decoded_trampoline_packet.encode(), encoded_trampoline_packet); + } + let msg = msgs::OutboundOnionPayload::TrampolineEntrypoint { multipath_trampoline_data: None, amt_to_forward: 0x0badf00d01020304, -- 2.39.5