### Install Honggfuzz Source: https://github.com/lightningdevkit/rust-lightning/blob/main/fuzz/README.md Installs the honggfuzz fuzzing engine. Use --force to overwrite existing installations. ```shell cargo update cargo install --force honggfuzz ``` -------------------------------- ### Install Honggfuzz with Specific Version Source: https://github.com/lightningdevkit/rust-lightning/blob/main/fuzz/README.md Pins and installs honggfuzz version 0.5.52. Useful for ensuring consistent behavior across environments. ```shell cargo update -p honggfuzz --precise "0.5.52" cargo install --force honggfuzz --version "0.5.52" ``` -------------------------------- ### Install cargo-fuzz Source: https://github.com/lightningdevkit/rust-lightning/blob/main/fuzz/README.md Installs the cargo-fuzz tool, which is a wrapper for libFuzzer. ```shell cargo update cargo install --force cargo-fuzz ``` -------------------------------- ### Run LDK Benchmarks Source: https://github.com/lightningdevkit/rust-lightning/blob/main/bench/README.md Execute the LDK benchmarks using cargo bench. Ensure RUSTFLAGS is set to include the ldk_bench configuration. ```bash RUSTFLAGS=--cfg=ldk_bench cargo bench ``` -------------------------------- ### Format Code with Rustfmt Source: https://github.com/lightningdevkit/rust-lightning/blob/main/CONTRIBUTING.md Run this command to format your code according to the project's standards before committing. Compliance is checked by CI. ```bash cargo +1.75.0 fmt ``` -------------------------------- ### Format Code in rust-lightning Source: https://github.com/lightningdevkit/rust-lightning/blob/main/AGENTS.md Apply code formatting to all files using cargo fmt. This step should be skipped if rust 1.75.0 is not installed. ```bash cargo +1.75.0 fmt --all ``` -------------------------------- ### Retrieve Last Rapid Gossip Sync Timestamp in Rust Source: https://github.com/lightningdevkit/rust-lightning/blob/main/lightning-rapid-gossip-sync/README.md Shows how to get the last timestamp used for a Rapid Gossip Sync operation directly from the NetworkGraph object. This avoids the need for additional caching mechanisms. ```rust let last_timestamp = network_graph.get_last_rapid_gossip_sync_timestamp(); ``` -------------------------------- ### Run Fuzz Tests with Honggfuzz (Colored Output) Source: https://github.com/lightningdevkit/rust-lightning/blob/main/fuzz/README.md A variation of the honggfuzz execution command that enables colored output for better readability. ```shell cargo --color always hfuzz run --manifest-path fuzz-fake-hashes/Cargo.toml $TARGET ``` -------------------------------- ### Run Fuzz Tests with Honggfuzz Source: https://github.com/lightningdevkit/rust-lightning/blob/main/fuzz/README.md Executes fuzz tests using honggfuzz. Requires setting environment variables for CPU count, build arguments, and run arguments. The TARGET variable specifies which fuzz target to run. ```shell cd fuzz export CPU_COUNT=1 # replace as needed export HFUZZ_BUILD_ARGS="--features honggfuzz_fuzz" export HFUZZ_RUN_ARGS="-n $CPU_COUNT --exit_upon_crash" export TARGET="msg_ping_target" # replace with the target to be fuzzed export RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz" cargo hfuzz run --manifest-path fuzz-fake-hashes/Cargo.toml $TARGET ``` -------------------------------- ### List Fuzzing Targets Source: https://github.com/lightningdevkit/rust-lightning/blob/main/fuzz/README.md Lists the available fuzzing target binaries within the specified directories. ```shell ls ./fuzz-fake-hashes/src/bin/ ls ./fuzz-real-hashes/src/bin/ ``` -------------------------------- ### Fast Fuzz Builds for Development with libFuzzer Source: https://github.com/lightningdevkit/rust-lightning/blob/main/fuzz/README.md Enables faster build times during development for libFuzzer fuzz targets by using the `-D` flag, which builds in development mode with optimizations. ```shell cd fuzz RUSTFLAGS="--cfg=fuzzing --cfg=secp256k1_fuzz --cfg=hashes_fuzz" \ cargo +nightly fuzz run --fuzz-dir fuzz-fake-hashes --features "libfuzzer_fuzz" -D msg_ping_target ```