]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Remove unnecessary feature test-only methods
authorJeffrey Czyz <jkczyz@gmail.com>
Wed, 14 Jul 2021 23:15:00 +0000 (16:15 -0700)
committerJeffrey Czyz <jkczyz@gmail.com>
Wed, 14 Jul 2021 23:26:08 +0000 (16:26 -0700)
lightning/src/ln/features.rs
lightning/src/routing/router.rs

index 9d865d15ec2bbc6f11e8ce39b2c970a0f48d4314..a9f5a10ee2dad14395e18eda253cbaba2943106c 100644 (file)
@@ -301,27 +301,7 @@ mod sealed {
                set_shutdown_any_segwit_required);
 
        #[cfg(test)]
-       define_context!(TestingContext {
-               required_features: [
-                       // Byte 0
-                       ,
-                       // Byte 1
-                       ,
-                       // Byte 2
-                       UnknownFeature,
-               ],
-               optional_features: [
-                       // Byte 0
-                       ,
-                       // Byte 1
-                       ,
-                       // Byte 2
-                       ,
-               ],
-       });
-
-       #[cfg(test)]
-       define_feature!(23, UnknownFeature, [TestingContext],
+       define_feature!(123456789, UnknownFeature, [NodeContext, ChannelContext],
                "Feature flags for an unknown feature used in testing.", set_unknown_feature_optional,
                set_unknown_feature_required);
 }
@@ -553,21 +533,6 @@ impl<T: sealed::Context> Features<T> {
        pub(crate) fn byte_count(&self) -> usize {
                self.flags.len()
        }
-
-       #[cfg(test)]
-       pub(crate) fn set_required_unknown_bits(&mut self) {
-               <sealed::TestingContext as sealed::UnknownFeature>::set_required_bit(&mut self.flags);
-       }
-
-       #[cfg(test)]
-       pub(crate) fn set_optional_unknown_bits(&mut self) {
-               <sealed::TestingContext as sealed::UnknownFeature>::set_optional_bit(&mut self.flags);
-       }
-
-       #[cfg(test)]
-       pub(crate) fn clear_unknown_bits(&mut self) {
-               <sealed::TestingContext as sealed::UnknownFeature>::clear_bits(&mut self.flags);
-       }
 }
 
 impl<T: sealed::DataLossProtect> Features<T> {
@@ -765,19 +730,15 @@ mod tests {
 
        #[test]
        fn sanity_test_unknown_bits() {
-               let mut features = ChannelFeatures::empty();
+               let features = ChannelFeatures::empty();
                assert!(!features.requires_unknown_bits());
                assert!(!features.supports_unknown_bits());
 
-               features.set_required_unknown_bits();
+               let features = ChannelFeatures::empty().set_unknown_feature_required();
                assert!(features.requires_unknown_bits());
                assert!(features.supports_unknown_bits());
 
-               features.clear_unknown_bits();
-               assert!(!features.requires_unknown_bits());
-               assert!(!features.supports_unknown_bits());
-
-               features.set_optional_unknown_bits();
+               let features = ChannelFeatures::empty().set_unknown_feature_optional();
                assert!(!features.requires_unknown_bits());
                assert!(features.supports_unknown_bits());
        }
index 6c14ebebd89b70d55b1e4f59af827a9f0a6b1cde..44b8c8a24aec4260a0b016c45ce774fd0b566354 100644 (file)
@@ -1992,8 +1992,7 @@ mod tests {
                let (_, our_id, privkeys, nodes) = get_nodes(&secp_ctx);
 
                // Disable nodes 1, 2, and 8 by requiring unknown feature bits
-               let mut unknown_features = NodeFeatures::known();
-               unknown_features.set_required_unknown_bits();
+               let unknown_features = NodeFeatures::known().set_unknown_feature_required();
                add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[0], unknown_features.clone(), 1);
                add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[1], unknown_features.clone(), 1);
                add_or_update_node(&net_graph_msg_handler, &secp_ctx, &privkeys[7], unknown_features.clone(), 1);