prysm-pulse/fuzz/ssz_encoder_attestations_fuzz.go
Everest Stefan Munro-Zeisberger ad269ee147
Set up Prysm for fuzz testing on Fuzzbuzz (#8789)
* Wrap beacon fuzz tests in go-fuzz compatible test functions

* Add fuzzbuzz.yaml
2021-04-19 19:00:46 +00:00

35 lines
793 B
Go

package fuzz
import (
"bytes"
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/encoder"
"github.com/prysmaticlabs/prysm/shared/params"
)
var buf = new(bytes.Buffer)
// FuzzSszEncoderAttestation wraps SszEncoderAttestationFuzz in a
// go-fuzz compatible interface
func FuzzSszEncoderAttestation(b []byte) int {
SszEncoderAttestationFuzz(b)
return 0
}
// SszEncoderAttestationFuzz runs network encode/decode for attestations.
func SszEncoderAttestationFuzz(b []byte) {
params.UseMainnetConfig()
buf.Reset()
input := &ethpb.Attestation{}
e := encoder.SszNetworkEncoder{}
if err := e.DecodeGossip(b, input); err != nil {
_ = err
return
}
if _, err := e.EncodeGossip(buf, input); err != nil {
_ = err
return
}
}