Browse Source

add gofuzz test for consensus wal

pull/965/head
Anton Kaliaev 7 years ago
parent
commit
709cf18aef
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 31 additions and 0 deletions
  1. +31
    -0
      consensus/wal_fuzz.go

+ 31
- 0
consensus/wal_fuzz.go View 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…
Cancel
Save