mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
add gofuzz test for consensus wal
This commit is contained in:
parent
e57cad6c3f
commit
709cf18aef
31
consensus/wal_fuzz.go
Normal file
31
consensus/wal_fuzz.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// +build gofuzz
|
||||||
|
|
||||||
|
package consensus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Fuzz(data []byte) int {
|
||||||
|
dec := NewWALDecoder(bytes.NewReader(data))
|
||||||
|
for {
|
||||||
|
msg, err := dec.Decode()
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
if msg != nil {
|
||||||
|
panic("msg != nil on error")
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var w bytes.Buffer
|
||||||
|
enc := NewWALEncoder(&w)
|
||||||
|
err = enc.Encode(msg)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user