Skip to content

Commit

Permalink
Set up Prysm for fuzz testing on Fuzzbuzz (#8789)
Browse files Browse the repository at this point in the history
* Wrap beacon fuzz tests in go-fuzz compatible test functions

* Add fuzzbuzz.yaml
  • Loading branch information
everestmz authored Apr 19, 2021
1 parent cff7dbd commit ad269ee
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fuzz/block_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ func (fakeChecker) Resync() error {
return nil
}

// FuzzBlock wraps BeaconFuzzBlock in a go-fuzz compatible interface
func FuzzBlock(b []byte) int {
BeaconFuzzBlock(b)
return 0
}

// BeaconFuzzBlock runs full processing of beacon block against a given state.
func BeaconFuzzBlock(b []byte) {
params.UseMainnetConfig()
Expand Down
6 changes: 6 additions & 0 deletions fuzz/rpc_status_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ func init() {
})
}

// FuzzP2PRPCStatus wraps BeaconFuzzP2PRPCStatus in a go-fuzz compatible interface
func FuzzP2PRPCStatus(b []byte) int {
BeaconFuzzP2PRPCStatus(b)
return 0
}

// BeaconFuzzP2PRPCStatus implements libfuzzer and beacon fuzz interface.
func BeaconFuzzP2PRPCStatus(b []byte) {
s, err := h.NewStream(context.Background(), p.PeerID(), "/eth2/beacon_chain/req/status/1/ssz_snappy")
Expand Down
7 changes: 7 additions & 0 deletions fuzz/ssz_encoder_attestations_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import (

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()
Expand Down
6 changes: 6 additions & 0 deletions fuzz/state_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ func init() {
})
}

// FuzzState wraps BeaconStateFuzz in a go-fuzz compatible interface
func FuzzState(b []byte) int {
BeaconStateFuzz(b)
return 0
}

// BeaconStateFuzz --
func BeaconStateFuzz(input []byte) {
params.UseMainnetConfig()
Expand Down
6 changes: 6 additions & 0 deletions fuzzbuzz.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
base:
language: go
docker_image: golang:latest
build_tags:
- libfuzzer
- blst_disabled

0 comments on commit ad269ee

Please sign in to comment.