tests/fuzzers: update fuzzers to be based on go-native fuzzing (#28352)

This change modifies the fuzzers to use the native golang fuzzing framework instead of go-fuzz
This commit is contained in:
Marius van der Wijden
2023-10-18 15:01:16 +02:00
committed by GitHub
parent da55b23d21
commit d10a2f6ab7
38 changed files with 639 additions and 560 deletions
+1 -1
View File
@@ -279,7 +279,7 @@ func (f *fuzzer) doFuzz(msgCode uint64, packet interface{}) {
fn(f, peer, func() bool { return true })
}
func Fuzz(input []byte) int {
func fuzz(input []byte) int {
// We expect some large inputs
if len(input) < 100 {
return -1
@@ -1,4 +1,4 @@
// Copyright 2020 The go-ethereum Authors
// Copyright 2023 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
@@ -14,27 +14,12 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package main
package les
import (
"fmt"
"os"
import "testing"
"github.com/ethereum/go-ethereum/tests/fuzzers/les"
)
func main() {
if len(os.Args) != 2 {
fmt.Fprintf(os.Stderr, "Usage: debug <file>\n")
fmt.Fprintf(os.Stderr, "Example\n")
fmt.Fprintf(os.Stderr, " $ debug ../crashers/4bbef6857c733a87ecf6fd8b9e7238f65eb9862a\n")
os.Exit(1)
}
crasher := os.Args[1]
data, err := os.ReadFile(crasher)
if err != nil {
fmt.Fprintf(os.Stderr, "error loading crasher %v: %v", crasher, err)
os.Exit(1)
}
les.Fuzz(data)
func Fuzz(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
fuzz(data)
})
}