Skip to content

feat: add initial fuzz testing infrastructure (closes #61)#475

Open
soloking1412 wants to merge 1 commit intobitcoindevkit:masterfrom
soloking1412:add-initial-fuzz
Open

feat: add initial fuzz testing infrastructure (closes #61)#475
soloking1412 wants to merge 1 commit intobitcoindevkit:masterfrom
soloking1412:add-initial-fuzz

Conversation

@soloking1412
Copy link
Copy Markdown

Description

Adds initial fuzz testing infrastructure to address #61. Built around cargo-fuzz (LibFuzzer), with three focused targets and CI integration.

New fuzz/ crate with three targets:

apply_update — structure-aware fuzzing of Wallet::apply_update. Generates arbitrary transactions, confirmation anchors, mempool timestamps, and chain checkpoints using the Arbitrary derive macro. After each run, asserts that the total wallet balance doesn't exceed 21M BTC.

create_tx — seeds the wallet with a known 100k-sat UTXO, then drives build_tx with arbitrary fee rates, amounts, drain mode, RBF signalling, and signing. CreateTxError variants are expected and swallowed — panics are bugs.

descriptor_parse — feeds arbitrary byte strings through IntoWalletDescriptor for both NetworkKind::Main and NetworkKind::Test. Exercises the full descriptor parsing pipeline: miniscript type-checking, key path validation, checksum verification.

Shared helpers (create_wallet, funding_update, p2wpkh_script) live in fuzz/src/lib.rs to keep new targets clean.

CI:

  • fuzz/ is a workspace member but excluded from all normal cargo build/test/clippy/doc runs so MSRV and no-std checks aren't affected.
  • New fuzz.yml workflow builds all targets on every PR (catches compile regressions) and runs each for 60 seconds on a weekly schedule, uploading crash artifacts on failure.

Running locally:

cargo install cargo-fuzz
cargo +nightly fuzz run apply_update
cargo +nightly fuzz run create_tx
cargo +nightly fuzz run descriptor_parse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant