From 69749fbe6a95f45eb7a695a5f89be87e55c91fb8 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Fri, 21 Feb 2020 15:57:02 +0000 Subject: [PATCH] tests: Add fuzzing harness for Golomb-Rice coding (GolombRiceEncode/GolombRiceDecode) --- src/Makefile.am | 1 + src/Makefile.test.include | 7 +++ src/blockfilter.cpp | 32 +--------- src/test/fuzz/golomb_rice.cpp | 112 ++++++++++++++++++++++++++++++++++ src/util/golombrice.h | 43 +++++++++++++ 5 files changed, 164 insertions(+), 31 deletions(-) create mode 100644 src/test/fuzz/golomb_rice.cpp create mode 100644 src/util/golombrice.h diff --git a/src/Makefile.am b/src/Makefile.am index ae95902f67..9a4fdfdacf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -215,6 +215,7 @@ BITCOIN_CORE_H = \ util/check.h \ util/error.h \ util/fees.h \ + util/golombrice.h \ util/spanparsing.h \ util/system.h \ util/macros.h \ diff --git a/src/Makefile.test.include b/src/Makefile.test.include index c3021743f4..4e88f7004b 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -37,6 +37,7 @@ FUZZ_TARGETS = \ test/fuzz/flat_file_pos_deserialize \ test/fuzz/flatfile \ test/fuzz/float \ + test/fuzz/golomb_rice \ test/fuzz/hex \ test/fuzz/integer \ test/fuzz/inv_deserialize \ @@ -483,6 +484,12 @@ test_fuzz_float_LDADD = $(FUZZ_SUITE_LD_COMMON) test_fuzz_float_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) test_fuzz_float_SOURCES = test/fuzz/float.cpp +test_fuzz_golomb_rice_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) +test_fuzz_golomb_rice_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) +test_fuzz_golomb_rice_LDADD = $(FUZZ_SUITE_LD_COMMON) +test_fuzz_golomb_rice_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +test_fuzz_golomb_rice_SOURCES = test/fuzz/golomb_rice.cpp + test_fuzz_hex_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) test_fuzz_hex_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) test_fuzz_hex_LDADD = $(FUZZ_SUITE_LD_COMMON) diff --git a/src/blockfilter.cpp b/src/blockfilter.cpp index 7aff3be6e7..5f5bed5bda 100644 --- a/src/blockfilter.cpp +++ b/src/blockfilter.cpp @@ -12,6 +12,7 @@ #include #include