Skip to content

Commit 4aae621

Browse files
committed
Fix fuzz tests
secp256k1 and bitcoin_hashes introduced new flags for fuzzing
1 parent 9f14d5e commit 4aae621

File tree

67 files changed

+395
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+395
-3
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ jobs:
192192
run: |
193193
cd fuzz && cargo update -p regex --precise "1.9.6" --verbose && cd ..
194194
- name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
195-
run: cd fuzz && RUSTFLAGS="--cfg=fuzzing" cargo test --verbose --color always
195+
run: cd fuzz && RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz" cargo test --verbose --color always
196196
- name: Run fuzzers
197197
run: cd fuzz && ./ci-fuzz.sh && cd ..
198198

ci/check-cfg-flags.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def check_target_os(os):
8282
def check_cfg_tag(cfg):
8383
if cfg == "fuzzing":
8484
pass
85+
elif cfg == "secp256k1_fuzz":
86+
pass
87+
elif cfg == "hashes_fuzz":
88+
pass
8589
elif cfg == "test":
8690
pass
8791
elif cfg == "debug_assertions":

fuzz/ci-fuzz.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ popd
1515

1616
cargo install --color always --force honggfuzz --no-default-features
1717
sed -i 's/lto = true//' Cargo.toml
18-
HFUZZ_BUILD_ARGS="--features honggfuzz_fuzz" cargo --color always hfuzz build
18+
19+
export RUSTFLAGS="--cfg=secp256k1_fuzz --cfg=hashes_fuzz"
20+
export HFUZZ_BUILD_ARGS="--features honggfuzz_fuzz"
21+
22+
cargo --color always hfuzz build
1923
for TARGET in src/bin/*.rs; do
2024
FILENAME=$(basename $TARGET)
2125
FILE="${FILENAME%.*}"
@@ -28,7 +32,7 @@ for TARGET in src/bin/*.rs; do
2832
HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -N1000000"
2933
fi
3034
export HFUZZ_RUN_ARGS
31-
HFUZZ_BUILD_ARGS="--features honggfuzz_fuzz" cargo --color always hfuzz run $FILE
35+
cargo --color always hfuzz run $FILE
3236
if [ -f hfuzz_workspace/$FILE/HONGGFUZZ.REPORT.TXT ]; then
3337
cat hfuzz_workspace/$FILE/HONGGFUZZ.REPORT.TXT
3438
for CASE in hfuzz_workspace/$FILE/SIG*; do

fuzz/src/bin/base32_target.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#[cfg(not(fuzzing))]
1616
compile_error!("Fuzz targets need cfg=fuzzing");
1717

18+
#[cfg(not(hashes_fuzz))]
19+
compile_error!("Fuzz targets need cfg=hashes_fuzz");
20+
21+
#[cfg(not(secp256k1_fuzz))]
22+
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");
23+
1824
extern crate lightning_fuzz;
1925
use lightning_fuzz::base32::*;
2026

fuzz/src/bin/bech32_parse_target.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#[cfg(not(fuzzing))]
1616
compile_error!("Fuzz targets need cfg=fuzzing");
1717

18+
#[cfg(not(hashes_fuzz))]
19+
compile_error!("Fuzz targets need cfg=hashes_fuzz");
20+
21+
#[cfg(not(secp256k1_fuzz))]
22+
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");
23+
1824
extern crate lightning_fuzz;
1925
use lightning_fuzz::bech32_parse::*;
2026

fuzz/src/bin/bolt11_deser_target.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#[cfg(not(fuzzing))]
1616
compile_error!("Fuzz targets need cfg=fuzzing");
1717

18+
#[cfg(not(hashes_fuzz))]
19+
compile_error!("Fuzz targets need cfg=hashes_fuzz");
20+
21+
#[cfg(not(secp256k1_fuzz))]
22+
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");
23+
1824
extern crate lightning_fuzz;
1925
use lightning_fuzz::bolt11_deser::*;
2026

fuzz/src/bin/chanmon_consistency_target.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#[cfg(not(fuzzing))]
1616
compile_error!("Fuzz targets need cfg=fuzzing");
1717

18+
#[cfg(not(hashes_fuzz))]
19+
compile_error!("Fuzz targets need cfg=hashes_fuzz");
20+
21+
#[cfg(not(secp256k1_fuzz))]
22+
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");
23+
1824
extern crate lightning_fuzz;
1925
use lightning_fuzz::chanmon_consistency::*;
2026

fuzz/src/bin/chanmon_deser_target.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#[cfg(not(fuzzing))]
1616
compile_error!("Fuzz targets need cfg=fuzzing");
1717

18+
#[cfg(not(hashes_fuzz))]
19+
compile_error!("Fuzz targets need cfg=hashes_fuzz");
20+
21+
#[cfg(not(secp256k1_fuzz))]
22+
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");
23+
1824
extern crate lightning_fuzz;
1925
use lightning_fuzz::chanmon_deser::*;
2026

fuzz/src/bin/fromstr_to_netaddress_target.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#[cfg(not(fuzzing))]
1616
compile_error!("Fuzz targets need cfg=fuzzing");
1717

18+
#[cfg(not(hashes_fuzz))]
19+
compile_error!("Fuzz targets need cfg=hashes_fuzz");
20+
21+
#[cfg(not(secp256k1_fuzz))]
22+
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");
23+
1824
extern crate lightning_fuzz;
1925
use lightning_fuzz::fromstr_to_netaddress::*;
2026

fuzz/src/bin/full_stack_target.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#[cfg(not(fuzzing))]
1616
compile_error!("Fuzz targets need cfg=fuzzing");
1717

18+
#[cfg(not(hashes_fuzz))]
19+
compile_error!("Fuzz targets need cfg=hashes_fuzz");
20+
21+
#[cfg(not(secp256k1_fuzz))]
22+
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");
23+
1824
extern crate lightning_fuzz;
1925
use lightning_fuzz::full_stack::*;
2026

0 commit comments

Comments
 (0)