mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-13 12:33:04 +02:00
multi: add fuzzer to make
This commit is contained in:
parent
986d889b74
commit
1c9de5652e
3 changed files with 28 additions and 0 deletions
1
.github/workflows/main.yml
vendored
1
.github/workflows/main.yml
vendored
|
|
@ -106,6 +106,7 @@ jobs:
|
|||
unit_type:
|
||||
- unit-race
|
||||
- unit-cover
|
||||
- fuzz
|
||||
steps:
|
||||
- name: git checkout
|
||||
uses: actions/checkout@v2
|
||||
|
|
|
|||
5
Makefile
5
Makefile
|
|
@ -12,6 +12,7 @@ GOIMPORTS_BIN := $(GO_BIN)/gosimports
|
|||
GOBUILD := go build -v
|
||||
GOINSTALL := go install -v
|
||||
GOTEST := go test -v
|
||||
GOFUZZ := go test -fuzztime 1m -fuzz
|
||||
|
||||
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -name "*pb.go" -not -name "*pb.gw.go" -not -name "*.pb.json.go")
|
||||
GOLIST := go list -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
|
||||
|
|
@ -100,6 +101,10 @@ unit-race:
|
|||
@$(call print, "Running unit race tests.")
|
||||
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE)
|
||||
|
||||
fuzz:
|
||||
@$(call print, "Running fuzz tests.")
|
||||
$(GOFUZZ) FuzzWitnessSpendDetection ./poolscript
|
||||
|
||||
# =============
|
||||
# FLAKE HUNTING
|
||||
# =============
|
||||
|
|
|
|||
|
|
@ -89,3 +89,25 @@ func TestIncrementBatchKey(t *testing.T) {
|
|||
|
||||
require.Equal(t, startBatchKey, currentKey)
|
||||
}
|
||||
|
||||
// FuzzWitnessSpendDetection fuzz tests the witness spend detection functions.
|
||||
func FuzzWitnessSpendDetection(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, a, b, c, d []byte, num uint8) {
|
||||
witness := make([][]byte, num)
|
||||
|
||||
if num > 0 {
|
||||
witness[0] = a
|
||||
}
|
||||
if num > 1 {
|
||||
witness[1] = b
|
||||
}
|
||||
if num > 2 {
|
||||
witness[2] = c
|
||||
}
|
||||
if num > 3 {
|
||||
witness[3] = d
|
||||
}
|
||||
_ = IsMultiSigSpend(witness)
|
||||
_ = IsExpirySpend(witness)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue