From 3a5f06069363f1ae739202aba98aeb8db7d529d1 Mon Sep 17 00:00:00 2001 From: Arthur Carcano Date: Thu, 7 May 2026 14:02:26 +0000 Subject: [PATCH] Add bucket_alias CRDT fuzz target (#1439) Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1439 Reviewed-by: Alex --- fuzz/Cargo.toml | 7 +++++++ fuzz/fuzz_targets/bucket_alias_crdt.rs | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 fuzz/fuzz_targets/bucket_alias_crdt.rs diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 1c3c26d8..15385d2f 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -57,3 +57,10 @@ path = "fuzz_targets/key_crdt.rs" test = false doc = false bench = false + +[[bin]] +name = "bucket_alias_crdt" +path = "fuzz_targets/bucket_alias_crdt.rs" +test = false +doc = false +bench = false diff --git a/fuzz/fuzz_targets/bucket_alias_crdt.rs b/fuzz/fuzz_targets/bucket_alias_crdt.rs new file mode 100644 index 00000000..9ab947d5 --- /dev/null +++ b/fuzz/fuzz_targets/bucket_alias_crdt.rs @@ -0,0 +1,25 @@ +#![no_main] + +use garage_fuzz::check_crdt_laws; +use garage_model::bucket_alias_table::BucketAlias; +use garage_util::data::Uuid; +use libfuzzer_sys::fuzz_target; + +/// Build a BucketAlias with a fixed name so that CRDT state can be compared +/// across merge results. The timestamp and optional bucket ID are the CRDT state. +fn make_bucket_alias(ts: u64, bucket_id: Option<[u8; 32]>) -> BucketAlias { + BucketAlias::new(String::new(), ts, bucket_id.map(Uuid::from)) +} + +fuzz_target!(|inputs: ( + (u64, Option<[u8; 32]>), + (u64, Option<[u8; 32]>), + (u64, Option<[u8; 32]>) +)| { + let ((ts1, b1), (ts2, b2), (ts3, b3)) = inputs; + check_crdt_laws( + make_bucket_alias(ts1, b1), + make_bucket_alias(ts2, b2), + make_bucket_alias(ts3, b3), + ); +});