Skip to content

Add fuzz tests implmentation - #68

Draft
ikripaka wants to merge 5 commits into
devfrom
feat/fuzz
Draft

ikripaka wants to merge 5 commits into
devfrom
feat/fuzz

Conversation

@ikripaka

Copy link
Copy Markdown
Collaborator
  • This PR suggests a bug fix and I've added the necessary tests.
  • This PR introduces a new feature and I've discussed the update in an Issue or with the team.
  • This PR is just a minor change like a typo fix.

* add description for u128, u256 tests, because they're much complexer than for ordinary ones
* add fuzzing in separate modules to separate logic
* introduce explicit Aliases for types in secp256k1::operations
@ikripaka

Copy link
Copy Markdown
Collaborator Author

Successfully ran fuzz tests on commit 4c37c1d with an updated mul_div_256 contract.

Testing was performed with 10_000 fuzz test cases for each test.
No failing test cases were found.

────────────
     Summary [92744.801s] 413 tests run: 413 passed (413 slow), 522 skipped
Exit Status: 0

run_fuzz_tests: finished with exit status 0

The script for running fuzz tests is the following:

#!/usr/bin/env bash
set -eo pipefail

main() {
  need_cmd simplex
  need_cmd tee

  local filter="${*:-all}"
  filter=${filter//[^[:alnum:]_.-]/_}
  filter=${filter:0:120}

  local log_file
  log_file="$(date +%Y-%m-%d_%H-%M-%S)_${filter}_$$.log"
  local status=0

  say "saving output to $log_file"

  # Include stderr: the test runner writes its progress and summary there.
  simplex test --fuzz "$@" --test-threads 10 --no-fail-fast -- --release --show-progress counter 2>&1 | tee "$log_file" || status=$?

  say "finished with exit status $status" | tee -a "$log_file"
  return "$status"
}

say() {
  printf 'run_fuzz_tests: %s\n' "$1"
}

err() {
  say "$*" >&2
  exit 1
}

need_cmd() {
  command -v "$1" > /dev/null 2>&1 || err "need '$1' (command not found)"
}

main "$@"

!/usr/bin/env bash

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant