]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Test blinded PaymentParameter round trip serialization.
authorValentine Wallace <vwallace@protonmail.com>
Mon, 19 Aug 2024 20:09:54 +0000 (16:09 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Mon, 19 Aug 2024 20:42:23 +0000 (16:42 -0400)
lightning/src/routing/router.rs

index c40e6ab3132c8f1919b1fcf4a4ffe97d2cc73041..4a2bdb31bbb1683a3372f793b867372c335be374 100644 (file)
@@ -3570,7 +3570,7 @@ mod tests {
        use crate::util::config::UserConfig;
        use crate::util::test_utils as ln_test_utils;
        use crate::crypto::chacha20::ChaCha20;
-       use crate::util::ser::{Readable, Writeable};
+       use crate::util::ser::{FixedLengthReader, Readable, ReadableArgs, Writeable};
        #[cfg(c_bindings)]
        use crate::util::ser::Writer;
 
@@ -7849,8 +7849,15 @@ mod tests {
                        features: BlindedHopFeatures::empty(),
                };
                let blinded_path = BlindedPaymentPath::from_raw(nodes[2], ln_test_utils::pubkey(42), blinded_hops, blinded_payinfo.clone());
+               let payment_params = PaymentParameters::blinded(vec![blinded_path.clone(), blinded_path.clone()]);
+
+               // Make sure we can round-trip read and write blinded payment params.
+               let encoded_params = payment_params.encode();
+               let mut s = Cursor::new(&encoded_params);
+               let mut reader = FixedLengthReader::new(&mut s, encoded_params.len() as u64);
+               let decoded_params: PaymentParameters = ReadableArgs::read(&mut reader, 42).unwrap();
+               assert_eq!(payment_params, decoded_params);
 
-               let payment_params = PaymentParameters::blinded(vec![blinded_path.clone()]);
                let route_params = RouteParameters::from_payment_params_and_value(
                        payment_params, 1001);
                let route = get_route(&our_id, &route_params, &network_graph, None, Arc::clone(&logger),