From: Arik Sosman Date: Thu, 18 Apr 2024 06:16:11 +0000 (-0700) Subject: Test Trampoline onion (de)serialization round trip. X-Git-Tag: v0.0.124-beta~112^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=98a926f07d32924fa118e711a43d129261390ea2;p=rust-lightning Test Trampoline onion (de)serialization round trip. --- 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,