From: Arik Sosman Date: Thu, 27 Jun 2024 14:30:21 +0000 (-0400) Subject: Test blinded Trampoline payload serialization. X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=f6b3004659ff50e644fbf1e77d1e8f9031e4172e;p=rust-lightning Test blinded Trampoline payload serialization. --- diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 4706793a6..7d6c045bf 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -3333,7 +3333,7 @@ mod tests { use crate::ln::types::ChannelId; use crate::types::payment::{PaymentPreimage, PaymentHash, PaymentSecret}; use crate::types::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures}; - use crate::ln::msgs::{self, FinalOnionHopData, OnionErrorPacket, CommonOpenChannelFields, CommonAcceptChannelFields, TrampolineOnionPacket}; + use crate::ln::msgs::{self, FinalOnionHopData, OnionErrorPacket, CommonOpenChannelFields, CommonAcceptChannelFields, OutboundTrampolinePayload, TrampolineOnionPacket}; use crate::ln::msgs::SocketAddress; use crate::routing::gossip::{NodeAlias, NodeId}; use crate::util::ser::{BigSize, FixedLengthReader, Hostname, LengthReadable, Readable, ReadableArgs, TransactionU16LenLimited, Writeable}; @@ -3359,6 +3359,8 @@ mod tests { #[cfg(feature = "std")] use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs}; + use types::features::{BlindedHopFeatures, Bolt12InvoiceFeatures}; + use crate::blinded_path::payment::{BlindedPayInfo, BlindedPaymentPath}; #[cfg(feature = "std")] use crate::ln::msgs::SocketAddressParseError; @@ -4706,6 +4708,36 @@ mod tests { assert_eq!(encoded_trampoline_packet, expected_eclair_trampoline_packet); } + #[test] + fn encoding_outbound_trampoline_payload() { + let mut trampoline_features = Bolt12InvoiceFeatures::empty(); + trampoline_features.set_basic_mpp_optional(); + let introduction_node = PublicKey::from_slice(&>::from_hex("032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991").unwrap()).unwrap(); + let blinding_point = PublicKey::from_slice(&>::from_hex("02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619").unwrap()).unwrap(); + let trampoline_payload = OutboundTrampolinePayload::LegacyBlindedPathEntry { + amt_to_forward: 150_000_000, + outgoing_cltv_value: 800_000, + payment_paths: vec![ + BlindedPaymentPath::from_raw( + introduction_node, + blinding_point, + vec![], + BlindedPayInfo{ + fee_base_msat: 500, + fee_proportional_millionths: 1_000, + cltv_expiry_delta: 36, + htlc_minimum_msat: 1, + htlc_maximum_msat: 500_000_000, + features: BlindedHopFeatures::empty(), + } + ) + ], + invoice_features: Some(trampoline_features), + }; + let serialized_payload = trampoline_payload.encode().to_lower_hex_string(); + assert_eq!(serialized_payload, "71020408f0d18004030c35001503020000165f032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e66868099102eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f28368661900000001f4000003e800240000000000000001000000001dcd65000000"); + } + #[test] fn query_channel_range_end_blocknum() { let tests: Vec<(u32, u32, u32)> = vec![