diff --git a/fuzz/fuzz_targets/area_rel_area_encoding_random.rs b/fuzz/fuzz_targets/area_rel_area_encoding_random.rs
index 7095e1d..8c43c98 100644
--- a/fuzz/fuzz_targets/area_rel_area_encoding_random.rs
+++ b/fuzz/fuzz_targets/area_rel_area_encoding_random.rs
@@ -3,14 +3,14 @@
use earthstar::identity_id::IdentityIdentifier as IdentityId;
use libfuzzer_sys::fuzz_target;
use willow_data_model::grouping::Area;
-use willow_fuzz::encode::relative_encoding_relation_random;
+use willow_fuzz::encode::relative_encoding_random;
fuzz_target!(|data: (&[u8], Area<16, 16, 16, IdentityId>)| {
// fuzzed code goes here
let (random_bytes, area) = data;
- relative_encoding_relation_random::, Area<16, 16, 16, IdentityId>>(
- area,
+ relative_encoding_random::, Area<16, 16, 16, IdentityId>>(
+ &area,
random_bytes,
)
});
diff --git a/fuzz/fuzz_targets/entry_rel_entry_encoding_random.rs b/fuzz/fuzz_targets/entry_rel_entry_encoding_random.rs
index befe28d..36d0bb2 100644
--- a/fuzz/fuzz_targets/entry_rel_entry_encoding_random.rs
+++ b/fuzz/fuzz_targets/entry_rel_entry_encoding_random.rs
@@ -4,7 +4,7 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId;
use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;
use libfuzzer_sys::fuzz_target;
use willow_data_model::Entry;
-use willow_fuzz::encode::relative_encoding_relation_random;
+use willow_fuzz::encode::relative_encoding_random;
use willow_fuzz::placeholder_params::FakePayloadDigest;
fuzz_target!(|data: (
@@ -13,8 +13,8 @@ fuzz_target!(|data: (
)| {
let (random_bytes, ref_entry) = data;
- relative_encoding_relation_random::<
+ relative_encoding_random::<
Entry<16, 16, 16, EsNamespaceId, IdentityId, FakePayloadDigest>,
Entry<16, 16, 16, EsNamespaceId, IdentityId, FakePayloadDigest>,
- >(ref_entry, random_bytes)
+ >(&ref_entry, random_bytes)
});
diff --git a/fuzz/fuzz_targets/entry_rel_namespace_area_encoding_random.rs b/fuzz/fuzz_targets/entry_rel_namespace_area_encoding_random.rs
index 0cc0d82..41aca5b 100644
--- a/fuzz/fuzz_targets/entry_rel_namespace_area_encoding_random.rs
+++ b/fuzz/fuzz_targets/entry_rel_namespace_area_encoding_random.rs
@@ -5,7 +5,7 @@ use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;
use libfuzzer_sys::fuzz_target;
use willow_data_model::grouping::Area;
use willow_data_model::Entry;
-use willow_fuzz::encode::relative_encoding_relation_random;
+use willow_fuzz::encode::relative_encoding_random;
use willow_fuzz::placeholder_params::FakePayloadDigest;
fuzz_target!(
@@ -13,9 +13,9 @@ fuzz_target!(
// fuzzed code goes here
let (random_bytes, namespaced_area) = data;
- relative_encoding_relation_random::<
+ relative_encoding_random::<
(EsNamespaceId, Area<16, 16, 16, IdentityId>),
Entry<16, 16, 16, EsNamespaceId, IdentityId, FakePayloadDigest>,
- >(namespaced_area, random_bytes)
+ >(&namespaced_area, random_bytes)
}
);
diff --git a/fuzz/fuzz_targets/entry_rel_namespace_range_encoding_random.rs b/fuzz/fuzz_targets/entry_rel_namespace_range_encoding_random.rs
index 018eb57..3916229 100644
--- a/fuzz/fuzz_targets/entry_rel_namespace_range_encoding_random.rs
+++ b/fuzz/fuzz_targets/entry_rel_namespace_range_encoding_random.rs
@@ -5,7 +5,7 @@ use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;
use libfuzzer_sys::fuzz_target;
use willow_data_model::grouping::Range3d;
use willow_data_model::Entry;
-use willow_fuzz::encode::relative_encoding_relation_random;
+use willow_fuzz::encode::relative_encoding_random;
use willow_fuzz::placeholder_params::FakePayloadDigest;
fuzz_target!(
@@ -13,9 +13,9 @@ fuzz_target!(
// fuzzed code goes here
let (random_bytes, namespaced_range_3d) = data;
- relative_encoding_relation_random::<
+ relative_encoding_random::<
(EsNamespaceId, Range3d<16, 16, 16, IdentityId>),
Entry<16, 16, 16, EsNamespaceId, IdentityId, FakePayloadDigest>,
- >(namespaced_range_3d, random_bytes);
+ >(&namespaced_range_3d, random_bytes);
}
);
diff --git a/fuzz/fuzz_targets/mc_capability_rel_area_encoding_random.rs b/fuzz/fuzz_targets/mc_capability_rel_area_encoding_random.rs
index 92e5922..2929927 100644
--- a/fuzz/fuzz_targets/mc_capability_rel_area_encoding_random.rs
+++ b/fuzz/fuzz_targets/mc_capability_rel_area_encoding_random.rs
@@ -3,14 +3,14 @@
use libfuzzer_sys::fuzz_target;
use meadowcap::McCapability;
use willow_data_model::grouping::Area;
-use willow_fuzz::encode::relative_encoding_canonical_random;
+use willow_fuzz::encode::relative_encoding_random;
use willow_fuzz::silly_sigs::{SillyPublicKey, SillySig};
fuzz_target!(|data: (&[u8], Area<3, 3, 3, SillyPublicKey>,)| {
let (random_bytes, out) = data;
- relative_encoding_canonical_random::<
+ relative_encoding_random::<
Area<3, 3, 3, SillyPublicKey>,
McCapability<3, 3, 3, SillyPublicKey, SillySig, SillyPublicKey, SillySig>,
- >(out, random_bytes)
+ >(&out, random_bytes)
});
diff --git a/fuzz/fuzz_targets/path_rel_path_encoding_random.rs b/fuzz/fuzz_targets/path_rel_path_encoding_random.rs
index 4ddd01b..644aeda 100644
--- a/fuzz/fuzz_targets/path_rel_path_encoding_random.rs
+++ b/fuzz/fuzz_targets/path_rel_path_encoding_random.rs
@@ -2,7 +2,7 @@
use libfuzzer_sys::fuzz_target;
use willow_data_model::Path;
-use willow_fuzz::encode::relative_encoding_canonical_random;
+use willow_fuzz::encode::relative_encoding_random;
const MCL: usize = 300;
const MCC: usize = 300;
@@ -11,8 +11,5 @@ const MPL: usize = 300;
fuzz_target!(|data: (&[u8], Path)| {
let (random_bytes, ref_path) = data;
- relative_encoding_canonical_random::, Path>(
- ref_path,
- random_bytes,
- )
+ relative_encoding_random::, Path>(&ref_path, random_bytes)
});
diff --git a/fuzz/fuzz_targets/path_rel_path_encoding_random2.rs b/fuzz/fuzz_targets/path_rel_path_encoding_random2.rs
index b473cfa..16d6e70 100644
--- a/fuzz/fuzz_targets/path_rel_path_encoding_random2.rs
+++ b/fuzz/fuzz_targets/path_rel_path_encoding_random2.rs
@@ -2,7 +2,7 @@
use libfuzzer_sys::fuzz_target;
use willow_data_model::Path;
-use willow_fuzz::encode::relative_encoding_canonical_random;
+use willow_fuzz::encode::relative_encoding_random;
const MCL: usize = 2;
const MCC: usize = 3;
@@ -11,8 +11,5 @@ const MPL: usize = 3;
fuzz_target!(|data: (&[u8], Path)| {
let (random_bytes, ref_path) = data;
- relative_encoding_canonical_random::, Path>(
- ref_path,
- random_bytes,
- )
+ relative_encoding_random::, Path>(&ref_path, random_bytes)
});
diff --git a/fuzz/fuzz_targets/path_rel_path_encoding_random3.rs b/fuzz/fuzz_targets/path_rel_path_encoding_random3.rs
index 175efcf..4275232 100644
--- a/fuzz/fuzz_targets/path_rel_path_encoding_random3.rs
+++ b/fuzz/fuzz_targets/path_rel_path_encoding_random3.rs
@@ -2,7 +2,7 @@
use libfuzzer_sys::fuzz_target;
use willow_data_model::Path;
-use willow_fuzz::encode::relative_encoding_canonical_random;
+use willow_fuzz::encode::relative_encoding_random;
const MCL: usize = 4;
const MCC: usize = 4;
@@ -11,8 +11,5 @@ const MPL: usize = 16;
fuzz_target!(|data: (&[u8], Path)| {
let (random_bytes, ref_path) = data;
- relative_encoding_canonical_random::, Path>(
- ref_path,
- random_bytes,
- )
+ relative_encoding_random::, Path>(&ref_path, random_bytes)
});
diff --git a/fuzz/fuzz_targets/range3d_rel_rang3d_encoding_random.rs b/fuzz/fuzz_targets/range3d_rel_rang3d_encoding_random.rs
index 49f9777..176e60c 100644
--- a/fuzz/fuzz_targets/range3d_rel_rang3d_encoding_random.rs
+++ b/fuzz/fuzz_targets/range3d_rel_rang3d_encoding_random.rs
@@ -3,14 +3,14 @@
use earthstar::identity_id::IdentityIdentifier as IdentityId;
use libfuzzer_sys::fuzz_target;
use willow_data_model::grouping::Range3d;
-use willow_fuzz::encode::relative_encoding_relation_random;
+use willow_fuzz::encode::relative_encoding_random;
fuzz_target!(|data: (&[u8], Range3d<16, 16, 16, IdentityId>)| {
// fuzzed code goes here
let (random_bytes, area) = data;
- relative_encoding_relation_random::<
- Range3d<16, 16, 16, IdentityId>,
- Range3d<16, 16, 16, IdentityId>,
- >(area, random_bytes);
+ relative_encoding_random::, Range3d<16, 16, 16, IdentityId>>(
+ &area,
+ random_bytes,
+ );
});
diff --git a/fuzz/src/encode.rs b/fuzz/src/encode.rs
index 22965f5..ca391f6 100644
--- a/fuzz/src/encode.rs
+++ b/fuzz/src/encode.rs
@@ -38,6 +38,14 @@ where
assert_eq!(decoded_item, item);
}
+pub fn encoding_random(data: &[u8])
+where
+ T: Encodable + Decodable + std::fmt::Debug + PartialEq + Eq,
+{
+ encoding_canonical_random::(data);
+ encoding_relation_random::(data);
+}
+
pub fn encoding_canonical_random(data: &[u8])
where
T: Encodable + Decodable + std::fmt::Debug,
@@ -145,14 +153,23 @@ pub fn relative_encoding_canonical_roundtrip(
assert_eq!(decoded_item, subject);
}
-pub fn relative_encoding_canonical_random(reference: R, data: &[u8])
+pub fn relative_encoding_random(reference: &R, data: &[u8])
+where
+ T: RelativeEncodable + RelativeDecodable + std::fmt::Debug + Eq,
+ R: std::fmt::Debug,
+{
+ relative_encoding_canonical_random::(reference, data);
+ relative_encoding_relation_random::(reference, data);
+}
+
+pub fn relative_encoding_canonical_random(reference: &R, data: &[u8])
where
T: RelativeEncodable + RelativeDecodable + std::fmt::Debug,
R: std::fmt::Debug,
{
let mut producer = FromSlice::new(data);
- match T::relative_decode_canonical(&reference, &mut producer) {
+ match T::relative_decode_canonical(reference, &mut producer) {
Ok(item) => {
// It decoded to a valid item! Gasp!
// Can we turn it back into the same encoding?
@@ -161,7 +178,7 @@ where
// println!("item {:?}", item);
// println!("ref {:?}", reference);
- item.relative_encode(&reference, &mut consumer).unwrap();
+ item.relative_encode(reference, &mut consumer).unwrap();
let encoded = consumer.as_ref();
@@ -180,14 +197,14 @@ where
};
}
-pub fn relative_encoding_relation_random(reference: R, data: &[u8])
+pub fn relative_encoding_relation_random(reference: &R, data: &[u8])
where
T: RelativeEncodable + RelativeDecodable + std::fmt::Debug + Eq,
R: std::fmt::Debug,
{
let mut producer = FromSlice::new(data);
- match T::relative_decode_relation(&reference, &mut producer) {
+ match T::relative_decode_relation(reference, &mut producer) {
Ok(item) => {
// It decoded to a valid item! Gasp!
// Can we turn it back into the same encoding?
@@ -196,11 +213,11 @@ where
// println!("item {:?}", item);
// println!("ref {:?}", reference);
- item.relative_encode(&reference, &mut consumer).unwrap();
+ item.relative_encode(reference, &mut consumer).unwrap();
let mut producer_2 = FromSlice::new(consumer.as_ref());
- match T::relative_decode_relation(&reference, &mut producer_2) {
+ match T::relative_decode_relation(reference, &mut producer_2) {
Ok(decoded_again) => {
assert_eq!(item, decoded_again);
}