Skip to content

Commit

Permalink
Fix fuzz tests
Browse files Browse the repository at this point in the history
secp256k1 and bitcoin_hashes introduced new flags for fuzzing
  • Loading branch information
jirijakes committed May 19, 2024
1 parent 9f14d5e commit 4aae621
Show file tree
Hide file tree
Showing 67 changed files with 395 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:
run: |
cd fuzz && cargo update -p regex --precise "1.9.6" --verbose && cd ..
- name: Sanity check fuzz targets on Rust ${{ env.TOOLCHAIN }}
run: cd fuzz && RUSTFLAGS="--cfg=fuzzing" cargo test --verbose --color always
run: cd fuzz && RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz" cargo test --verbose --color always
- name: Run fuzzers
run: cd fuzz && ./ci-fuzz.sh && cd ..

Expand Down
4 changes: 4 additions & 0 deletions ci/check-cfg-flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def check_target_os(os):
def check_cfg_tag(cfg):
if cfg == "fuzzing":
pass
elif cfg == "secp256k1_fuzz":
pass
elif cfg == "hashes_fuzz":
pass
elif cfg == "test":
pass
elif cfg == "debug_assertions":
Expand Down
8 changes: 6 additions & 2 deletions fuzz/ci-fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ popd

cargo install --color always --force honggfuzz --no-default-features
sed -i 's/lto = true//' Cargo.toml
HFUZZ_BUILD_ARGS="--features honggfuzz_fuzz" cargo --color always hfuzz build

export RUSTFLAGS="--cfg=secp256k1_fuzz --cfg=hashes_fuzz"
export HFUZZ_BUILD_ARGS="--features honggfuzz_fuzz"

cargo --color always hfuzz build
for TARGET in src/bin/*.rs; do
FILENAME=$(basename $TARGET)
FILE="${FILENAME%.*}"
Expand All @@ -28,7 +32,7 @@ for TARGET in src/bin/*.rs; do
HFUZZ_RUN_ARGS="$HFUZZ_RUN_ARGS -N1000000"
fi
export HFUZZ_RUN_ARGS
HFUZZ_BUILD_ARGS="--features honggfuzz_fuzz" cargo --color always hfuzz run $FILE
cargo --color always hfuzz run $FILE
if [ -f hfuzz_workspace/$FILE/HONGGFUZZ.REPORT.TXT ]; then
cat hfuzz_workspace/$FILE/HONGGFUZZ.REPORT.TXT
for CASE in hfuzz_workspace/$FILE/SIG*; do
Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/base32_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::base32::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/bech32_parse_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::bech32_parse::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/bolt11_deser_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::bolt11_deser::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/chanmon_consistency_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::chanmon_consistency::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/chanmon_deser_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::chanmon_deser::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/fromstr_to_netaddress_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::fromstr_to_netaddress::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/full_stack_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::full_stack::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/indexedmap_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::indexedmap::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/invoice_deser_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::invoice_deser::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/invoice_request_deser_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::invoice_request_deser::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_accept_channel_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_accept_channel::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_accept_channel_v2_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_accept_channel_v2::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_announcement_signatures_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_announcement_signatures::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_channel_announcement_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_channel_announcement::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_channel_details_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_channel_details::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_channel_ready_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_channel_ready::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_channel_reestablish_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_channel_reestablish::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_channel_update_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_channel_update::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_closing_signed_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_closing_signed::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_commitment_signed_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_commitment_signed::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_decoded_onion_error_packet_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_decoded_onion_error_packet::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_error_message_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_error_message::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_funding_created_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_funding_created::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_funding_signed_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_funding_signed::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_gossip_timestamp_filter_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_gossip_timestamp_filter::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_init_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_init::*;

Expand Down
6 changes: 6 additions & 0 deletions fuzz/src/bin/msg_node_announcement_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#[cfg(not(fuzzing))]
compile_error!("Fuzz targets need cfg=fuzzing");

#[cfg(not(hashes_fuzz))]
compile_error!("Fuzz targets need cfg=hashes_fuzz");

#[cfg(not(secp256k1_fuzz))]
compile_error!("Fuzz targets need cfg=secp256k1_fuzz");

extern crate lightning_fuzz;
use lightning_fuzz::msg_targets::msg_node_announcement::*;

Expand Down
Loading

0 comments on commit 4aae621

Please sign in to comment.