diff --git a/common/bitutil/compress_fuzz.go b/tests/fuzzers/bitutil/compress_fuzz.go
similarity index 84%
rename from common/bitutil/compress_fuzz.go
rename to tests/fuzzers/bitutil/compress_fuzz.go
index 714bbcd131d5..5f241255248e 100644
--- a/common/bitutil/compress_fuzz.go
+++ b/tests/fuzzers/bitutil/compress_fuzz.go
@@ -14,11 +14,13 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-// +build gofuzz
-
package bitutil
-import "bytes"
+import (
+ "bytes"
+
+ "github.com/XinFinOrg/XDPoSChain/common/bitutil"
+)
// Fuzz implements a go-fuzz fuzzer method to test various encoding method
// invocations.
@@ -35,7 +37,7 @@ func Fuzz(data []byte) int {
// fuzzEncode implements a go-fuzz fuzzer method to test the bitset encoding and
// decoding algorithm.
func fuzzEncode(data []byte) int {
- proc, _ := bitsetDecodeBytes(bitsetEncodeBytes(data), len(data))
+ proc, _ := bitutil.DecompressBytes(bitutil.CompressBytes(data), len(data))
if !bytes.Equal(data, proc) {
panic("content mismatch")
}
@@ -45,11 +47,11 @@ func fuzzEncode(data []byte) int {
// fuzzDecode implements a go-fuzz fuzzer method to test the bit decoding and
// reencoding algorithm.
func fuzzDecode(data []byte) int {
- blob, err := bitsetDecodeBytes(data, 1024)
+ blob, err := bitutil.DecompressBytes(data, 1024)
if err != nil {
return 0
}
- if comp := bitsetEncodeBytes(blob); !bytes.Equal(comp, data) {
+ if comp := bitutil.CompressBytes(blob); !bytes.Equal(comp, data) {
panic("content mismatch")
}
return 1
diff --git a/crypto/bn256/bn256_fuzz.go b/tests/fuzzers/bn256/bn256_fuzz.go
similarity index 95%
rename from crypto/bn256/bn256_fuzz.go
rename to tests/fuzzers/bn256/bn256_fuzz.go
index c3e1833ef2df..d735745185b3 100644
--- a/crypto/bn256/bn256_fuzz.go
+++ b/tests/fuzzers/bn256/bn256_fuzz.go
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-// +build gofuzz
-
package bn256
import (
@@ -36,7 +34,7 @@ func getG1Points(input io.Reader) (*cloudflare.G1, *google.G1) {
}
xg := new(google.G1)
if _, err := xg.Unmarshal(xc.Marshal()); err != nil {
- panic(fmt.Sprintf("Could not marshal cloudflare -> google:", err))
+ panic(fmt.Sprintf("Could not marshal cloudflare -> google: %v", err))
}
return xc, xg
}
@@ -49,7 +47,7 @@ func getG2Points(input io.Reader) (*cloudflare.G2, *google.G2) {
}
xg := new(google.G2)
if _, err := xg.Unmarshal(xc.Marshal()); err != nil {
- panic(fmt.Sprintf("Could not marshal cloudflare -> google:", err))
+ panic(fmt.Sprintf("Could not marshal cloudflare -> google: %v", err))
}
return xc, xg
}
diff --git a/core/vm/runtime/fuzz.go b/tests/fuzzers/runtime/runtime_fuzz.go
similarity index 82%
rename from core/vm/runtime/fuzz.go
rename to tests/fuzzers/runtime/runtime_fuzz.go
index cb9ff08b5b08..c05254fab9ef 100644
--- a/core/vm/runtime/fuzz.go
+++ b/tests/fuzzers/runtime/runtime_fuzz.go
@@ -14,23 +14,23 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see .
-// +build gofuzz
-
package runtime
+import (
+ "github.com/XinFinOrg/XDPoSChain/core/vm/runtime"
+)
+
// Fuzz is the basic entry point for the go-fuzz tool
//
// This returns 1 for valid parsable/runable code, 0
// for invalid opcode.
func Fuzz(input []byte) int {
- _, _, err := Execute(input, input, &Config{
- GasLimit: 3000000,
+ _, _, err := runtime.Execute(input, input, &runtime.Config{
+ GasLimit: 12000000,
})
-
// invalid opcode
- if err != nil && len(err.Error()) > 6 && string(err.Error()[:7]) == "invalid" {
+ if err != nil && len(err.Error()) > 6 && err.Error()[:7] == "invalid" {
return 0
}
-
return 1
}