feat(gnovm): add gno fuzz for gno test #3442
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Title: Add Fuzzing Support for cmd with Enhanced Options
Description:
This PR introduces a fuzzing mechanism to the cmd following Go's fuzzing approach. The new functionality includes the following features and usage:
Usage:
Command: cmd supports a fuzzing mechanism similar to Go's built-in fuzzing framework.
FuzzXXX Function:
The FuzzXXX function should follow the standard signature where f.Fuzz accepts a function with the format:
f.Fuzz(func(t *testing.T, orig ...interface{}) {})
Example Code:
func FuzzMock(f *testing.F) {
f.Add("apple hello", int(400002131323))
f.Add("rainy day", int(98401132231331))
f.Add("winter comes", int(12349123123))
f.Fuzz(func(t *testing.T, orig ...interface{}) {
v, ok := orig[0].(string)
if !ok {
panic("type mismatch")
}
i, ok2 := orig[1].(int)
if !ok2 {
panic("type mismatch")
}
rev := testing.Reverse1(v)
doubleRev := testing.Reverse1(rev)
if v != doubleRev && i > 300 && i < 500 {
t.Errorf("Before: %q, after: %q", orig, doubleRev)
}
if utf8.ValidString(v) && !utf8.ValidString(rev) && i > 300 && i < 1000 {
t.Errorf("Reverse produced invalid UTF-8 string %q", rev)
}
})
}
Example Command: