From 06ecbecd6d5944281bbe1f1407114af49eb293d3 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Wed, 14 Jul 2021 16:15:00 -0700 Subject: [PATCH] Remove unnecessary feature test-only methods --- lightning/src/ln/features.rs | 47 +++------------------------------ lightning/src/routing/router.rs | 3 +-- 2 files changed, 5 insertions(+), 45 deletions(-) diff --git a/lightning/src/ln/features.rs b/lightning/src/ln/features.rs index 9d865d15e..a9f5a10ee 100644 --- a/lightning/src/ln/features.rs +++ b/lightning/src/ln/features.rs @@ -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 Features { pub(crate) fn byte_count(&self) -> usize { self.flags.len() } - - #[cfg(test)] - pub(crate) fn set_required_unknown_bits(&mut self) { - ::set_required_bit(&mut self.flags); - } - - #[cfg(test)] - pub(crate) fn set_optional_unknown_bits(&mut self) { - ::set_optional_bit(&mut self.flags); - } - - #[cfg(test)] - pub(crate) fn clear_unknown_bits(&mut self) { - ::clear_bits(&mut self.flags); - } } impl Features { @@ -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()); } diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 6c14ebebd..44b8c8a24 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -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); -- 2.39.5