What changed, and why it matters
This commit only renames existing test functions and adds one new internal policy test to verify that a public type implements the Arbitrary trait when the optional 'arbitrary' feature is enabled. It does not change any production code, cryptographic logic, network handling, or security behavior.
No security action needed; this is a routine test-maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies network/tests/api.rs, a test-only file. Existing API-guideline tests are renamed from descriptive names (e.g., api_all_types_implement_send_sync) to Rust API guideline convention names (e.g., c_send_sync). A new test, p_arbitrary, gated by #[cfg(feature = “arbitrary”)], asserts that NetworkKind implements arbitrary::Arbitrary. No runtime or library code is changed.
Changed components
network/tests/api.rsInspect captured patch +20 / −10
diff --git a/network/tests/api.rs b/network/tests/api.rs
index 280fd5e3..03cd7e74 100644
--- a/network/tests/api.rs
+++ b/network/tests/api.rs
@@ -1,10 +1,8 @@
// SPDX-License-Identifier: CC0-1.0
-//! Test the API surface of `bitcoin-network-kind`.
+//! Test the API surface (not functionality) of `bitcoin-network-kind`.
//!
-//! The point of these tests is to check the API surface as opposed to test the API functionality.
-//!
-//! See [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/about.html).
+//! See [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/about.html) and the [rust-bitcoin policies](../../docs/policy.md).
#![allow(dead_code)]
#![allow(unused_imports)]
@@ -12,6 +10,9 @@
use core::fmt;
use core::str::FromStr;
+#[cfg(feature = "arbitrary")]
+use arbitrary::Arbitrary;
+
use bitcoin_network_kind::{Network, NetworkKind, ParseNetworkError, TestnetVersion};
/// A struct that includes all public non-error enums.
@@ -41,7 +42,7 @@ impl Errors {
/// C-SEND-SYNC: Tests that all public types implement `Send` + `Sync`.
#[test]
-fn api_all_types_implement_send_sync() {
+fn c_send_sync() {
fn is_send_sync<T: Send + Sync>() {}
is_send_sync::<Enums>();
@@ -50,7 +51,7 @@ fn api_all_types_implement_send_sync() {
/// C-DEBUG-NONEMPTY: Tests that all public types have non-empty Debug.
#[test]
-fn api_all_types_have_non_empty_debug() {
+fn c_debug_nonempty() {
let enums = Enums::new();
let errors = Errors::new();
@@ -62,7 +63,7 @@ fn api_all_types_have_non_empty_debug() {
/// C-GOOD-ERR: Tests that all public error types implement Display.
#[test]
-fn api_all_error_types_implement_display() {
+fn c_good_err_display() {
fn assert_display<T: fmt::Display>() {}
assert_display::<ParseNetworkError>();
@@ -71,7 +72,7 @@ fn api_all_error_types_implement_display() {
/// C-GOOD-ERR: Tests that all public error types implement [`std::error::Error`].
#[test]
#[cfg(feature = "std")]
-fn api_all_error_types_implement_error() {
+fn c_good_err_error() {
fn assert_error<T: std::error::Error>() {}
assert_error::<ParseNetworkError>();
@@ -79,7 +80,7 @@ fn api_all_error_types_implement_error() {
/// C-CONV-TRAITS: Tests that conversion traits are implemented where expected.
#[test]
-fn api_conversion_traits_implemented() {
+fn c_conv_traits() {
fn assert_from<T: From<U>, U>() {}
fn assert_fromstr<T: FromStr>() {}
fn assert_asref_self<T: AsRef<T>>() {}
@@ -92,9 +93,18 @@ fn api_conversion_traits_implemented() {
/// C-SERDE: Tests that serde traits are implemented where expected.
#[test]
#[cfg(feature = "serde")]
-fn api_serde_traits_implemented() {
+fn c_serde() {
fn assert_serde<T: serde::Serialize + for<'de> serde::Deserialize<'de>>() {}
assert_serde::<NetworkKind>();
assert_serde::<Network>();
}
+
+/// P-ARBITRARY: Tests that public types implement `Arbitrary`.
+#[test]
+#[cfg(feature = "arbitrary")]
+fn p_arbitrary() {
+ fn assert_arbitrary<T: for<'a> Arbitrary<'a>>() {}
+
+ assert_arbitrary::<NetworkKind>();
+}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.