From: Jeffrey Czyz Date: Wed, 14 Jul 2021 23:15:00 +0000 (-0700) Subject: Remove unnecessary feature test-only methods X-Git-Tag: v0.0.100~26^2~1 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=06ecbecd6d5944281bbe1f1407114af49eb293d3;p=rust-lightning Remove unnecessary feature test-only methods --- 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);