prysm-pulse/fuzz/attestation_fuzz.go
Raul Jordan 302b0f8c80
Use FastSSZ Everywhere Applicable (#6135)
* use fast ssz anywhere applicable
* use fastssz clearly
* Merge branch 'master' into use-fastssz
* Apply suggestions from code review
* imports
* Update beacon-chain/p2p/fork.go
* Merge branch 'master' into use-fastssz
* update go-ssz
* update go-ssz
* Merge refs/heads/master into use-fastssz
* Merge refs/heads/master into use-fastssz
2020-06-05 13:48:40 +00:00

34 lines
885 B
Go

package fuzz
import (
"context"
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
prylabs_testing "github.com/prysmaticlabs/prysm/fuzz/testing"
"github.com/prysmaticlabs/prysm/shared/params"
)
// BeaconFuzzAttestation implements libfuzzer and beacon fuzz interface.
func BeaconFuzzAttestation(b []byte) ([]byte, bool) {
params.UseMainnetConfig()
input := &InputAttestationWrapper{}
if err := input.UnmarshalSSZ(b); err != nil {
return fail(err)
}
s, err := prylabs_testing.GetBeaconFuzzState(input.StateID)
if err != nil || s == nil {
return nil, false
}
st, err := stateTrie.InitializeFromProto(s)
if err != nil {
return fail(err)
}
post, err := blocks.ProcessAttestationNoVerify(context.Background(), st, input.Attestation)
if err != nil {
return fail(err)
}
return success(post)
}