Support option_data_loss_protect for remote peer
[rust-lightning] / src / ln / msgs.rs
index 10e83e08ddeec17b114a3aea31b7bf8dfabe9332..0e6c4b95ee32645d4e43a5ead08331e99d4784f6 100644 (file)
@@ -60,19 +60,22 @@ pub struct LocalFeatures {
 
 impl LocalFeatures {
        /// Create a blank LocalFeatures flags (visibility extended for fuzz tests)
+       #[cfg(not(feature = "fuzztarget"))]
+       pub(crate) fn new() -> LocalFeatures {
+               LocalFeatures {
+                       flags: vec![2 | 1 << 5],
+               }
+       }
+       #[cfg(feature = "fuzztarget")]
        pub fn new() -> LocalFeatures {
                LocalFeatures {
-                       flags: Vec::new(),
+                       flags: vec![2 | 1 << 5],
                }
        }
 
        pub(crate) fn supports_data_loss_protect(&self) -> bool {
                self.flags.len() > 0 && (self.flags[0] & 3) != 0
        }
-       pub(crate) fn requires_data_loss_protect(&self) -> bool {
-               self.flags.len() > 0 && (self.flags[0] & 1) != 0
-       }
-
        pub(crate) fn initial_routing_sync(&self) -> bool {
                self.flags.len() > 0 && (self.flags[0] & (1 << 3)) != 0
        }
@@ -87,8 +90,9 @@ impl LocalFeatures {
        pub(crate) fn supports_upfront_shutdown_script(&self) -> bool {
                self.flags.len() > 0 && (self.flags[0] & (3 << 4)) != 0
        }
-       pub(crate) fn requires_upfront_shutdown_script(&self) -> bool {
-               self.flags.len() > 0 && (self.flags[0] & (1 << 4)) != 0
+       #[cfg(test)]
+       pub(crate) fn unset_upfront_shutdown_script(&mut self) {
+               self.flags[0] ^= 1 << 5;
        }
 
        pub(crate) fn requires_unknown_bits(&self) -> bool {
@@ -706,7 +710,6 @@ mod fuzzy_internal_msgs {
                pub(crate) data: OnionRealm0HopData,
                pub(crate) hmac: [u8; 32],
        }
-       unsafe impl ::util::internal_traits::NoDealloc for OnionHopData{}
 
        pub struct DecodedOnionErrorPacket {
                pub(crate) hmac: [u8; 32],
@@ -2011,9 +2014,9 @@ mod tests {
                        target_value.append(&mut hex::decode("0000").unwrap());
                }
                if initial_routing_sync {
-                       target_value.append(&mut hex::decode("000108").unwrap());
+                       target_value.append(&mut hex::decode("00012a").unwrap());
                } else {
-                       target_value.append(&mut hex::decode("0000").unwrap());
+                       target_value.append(&mut hex::decode("000122").unwrap());
                }
                assert_eq!(encoded_value, target_value);
        }