mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-07 11:32:20 +00:00
add fuzz example
This commit is contained in:
parent
5ab4e6efdc
commit
242cb412f7
28
txpool/pool_fuzz.go
Normal file
28
txpool/pool_fuzz.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// +build gofuzzbeta
|
||||||
|
|
||||||
|
package txpool
|
||||||
|
|
||||||
|
// https://blog.golang.org/fuzz-beta
|
||||||
|
// golang.org/s/draft-fuzzing-design
|
||||||
|
//gotip doc testing
|
||||||
|
//gotip doc testing.F
|
||||||
|
//gotip doc testing.F.Add
|
||||||
|
//gotip doc testing.F.Fuzz
|
||||||
|
|
||||||
|
func FuzzParseQuery(f *testing.F) {
|
||||||
|
f.Add("x=1&y=2")
|
||||||
|
f.Fuzz(func(t *testing.T, queryStr string) {
|
||||||
|
query, err := url.ParseQuery(queryStr)
|
||||||
|
if err != nil {
|
||||||
|
t.Skip()
|
||||||
|
}
|
||||||
|
queryStr2 := query.Encode()
|
||||||
|
query2, err := url.ParseQuery(queryStr2)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("ParseQuery failed to decode a valid encoded query %s: %v", queryStr2, err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(query, query2) {
|
||||||
|
t.Errorf("ParseQuery gave different query after being encoded\nbefore: %v\nafter: %v", query, query2)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user