From f757991635e31c73e6995522ca37a4689c1a8627 Mon Sep 17 00:00:00 2001 From: Arthur Carcano Date: Thu, 7 May 2026 11:27:14 +0000 Subject: [PATCH] Add block_ref CRDT fuzz target (#1440) Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1440 Reviewed-by: Alex --- fuzz/Cargo.toml | 7 +++++++ fuzz/fuzz_targets/block_ref_crdt.rs | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 fuzz/fuzz_targets/block_ref_crdt.rs diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 108dccf4..03ecf3be 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -36,3 +36,10 @@ path = "fuzz_targets/bucket_crdt.rs" test = false doc = false bench = false + +[[bin]] +name = "block_ref_crdt" +path = "fuzz_targets/block_ref_crdt.rs" +test = false +doc = false +bench = false diff --git a/fuzz/fuzz_targets/block_ref_crdt.rs b/fuzz/fuzz_targets/block_ref_crdt.rs new file mode 100644 index 00000000..48e43443 --- /dev/null +++ b/fuzz/fuzz_targets/block_ref_crdt.rs @@ -0,0 +1,20 @@ +#![no_main] + +use garage_fuzz::check_crdt_laws; +use garage_model::s3::block_ref_table::BlockRef; +use libfuzzer_sys::fuzz_target; + +/// Build a BlockRef with a fixed block hash and version UUID so that CRDT state +/// can be compared across merge results. Only the deleted flag varies. +fn make_block_ref(deleted: bool) -> BlockRef { + BlockRef { + block: [0u8; 32].into(), + version: [0u8; 32].into(), + deleted: deleted.into(), + } +} + +fuzz_target!(|inputs: (bool, bool, bool)| { + let (d1, d2, d3) = inputs; + check_crdt_laws(make_block_ref(d1), make_block_ref(d2), make_block_ref(d3)); +});