Skip to content

Commit c787198

Browse files
committed
Test blinded Trampoline payload serialization.
1 parent 9314553 commit c787198

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lightning/src/ln/msgs.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,7 @@ mod tests {
33253325
use bitcoin::hex::DisplayHex;
33263326
use crate::ln::types::{ChannelId, PaymentPreimage, PaymentHash, PaymentSecret};
33273327
use crate::ln::features::{ChannelFeatures, ChannelTypeFeatures, InitFeatures, NodeFeatures};
3328-
use crate::ln::msgs::{self, FinalOnionHopData, OnionErrorPacket, CommonOpenChannelFields, CommonAcceptChannelFields, TrampolineOnionPacket};
3328+
use crate::ln::msgs::{self, FinalOnionHopData, OnionErrorPacket, CommonOpenChannelFields, CommonAcceptChannelFields, TrampolineOnionPacket, OutboundTrampolinePayload};
33293329
use crate::ln::msgs::SocketAddress;
33303330
use crate::routing::gossip::{NodeAlias, NodeId};
33313331
use crate::util::ser::{BigSize, FixedLengthReader, Hostname, LengthReadable, Readable, ReadableArgs, TransactionU16LenLimited, Writeable};
@@ -3351,6 +3351,7 @@ mod tests {
33513351

33523352
#[cfg(feature = "std")]
33533353
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
3354+
use crate::blinded_path::{BlindedPath, Direction, IntroductionNode};
33543355
#[cfg(feature = "std")]
33553356
use crate::ln::msgs::SocketAddressParseError;
33563357

@@ -4698,6 +4699,25 @@ mod tests {
46984699
assert_eq!(encoded_trampoline_packet, expected_eclair_trampoline_packet);
46994700
}
47004701

4702+
#[test]
4703+
fn encoding_outbound_trampoline_payload() {
4704+
let public_key = PublicKey::from_slice(&<Vec<u8>>::from_hex("02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619").unwrap()).unwrap();
4705+
let trampoline_payload = OutboundTrampolinePayload::BlindedForward {
4706+
amt_to_forward: 100000000,
4707+
outgoing_cltv_value: 800000,
4708+
payment_paths: vec![
4709+
BlindedPath {
4710+
introduction_node: IntroductionNode::DirectedShortChannelId(Direction::NodeOne, 12),
4711+
blinding_point: public_key,
4712+
blinded_hops: vec![],
4713+
}
4714+
],
4715+
invoice_features: None,
4716+
};
4717+
let serialized_payload = trampoline_payload.encode().to_lower_hex_string();
4718+
assert_eq!(serialized_payload, "3c020405f5e10004030c3500fe000102362b00000000000000000c02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f28368661900");
4719+
}
4720+
47014721
#[test]
47024722
fn query_channel_range_end_blocknum() {
47034723
let tests: Vec<(u32, u32, u32)> = vec![

0 commit comments

Comments
 (0)