From b54fc820e92dd9a264267bcc07a36d5503e29887 Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Tue, 31 Mar 2026 22:42:45 +0200 Subject: [PATCH] radicle/tor: Fixes Fixes two earlier mistakes: 1. In `fb18083`, `fn null_to_default` was added, which is only conditionally used if the feature "tor" is enabled, so also only conditionally compile the function. 2. In `1e13268`, the `impl Arbitrary` for AddressType` was not properly adjusted for the case where the newly introduced feature "tor" is disabled. --- crates/radicle/src/serde_ext.rs | 1 + crates/radicle/src/test/arbitrary.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/radicle/src/serde_ext.rs b/crates/radicle/src/serde_ext.rs index 0be4643d..b1b06d23 100644 --- a/crates/radicle/src/serde_ext.rs +++ b/crates/radicle/src/serde_ext.rs @@ -47,6 +47,7 @@ where } /// Deserialize a value, but if it is `null`, return the default value. +#[cfg(feature = "tor")] pub(crate) fn null_to_default<'de, D, T>(deserializer: D) -> Result where T: serde::Deserialize<'de> + Default, diff --git a/crates/radicle/src/test/arbitrary.rs b/crates/radicle/src/test/arbitrary.rs index f77e300c..d08e0954 100644 --- a/crates/radicle/src/test/arbitrary.rs +++ b/crates/radicle/src/test/arbitrary.rs @@ -208,7 +208,12 @@ impl Arbitrary for MockRepository { impl Arbitrary for AddressType { fn arbitrary(g: &mut qcheck::Gen) -> Self { - let t = *g.choose(&[1, 2, 3, 4]).unwrap() as u8; + #[cfg(not(feature = "tor"))] + let types = [1, 2, 3]; + #[cfg(feature = "tor")] + let types = [1, 2, 3, 4]; + + let t = *g.choose(&types).unwrap() as u8; AddressType::try_from(t).unwrap() }