Skip to content

Commit ad269ee

Browse files
authored
Set up Prysm for fuzz testing on Fuzzbuzz (#8789)
* Wrap beacon fuzz tests in go-fuzz compatible test functions * Add fuzzbuzz.yaml
1 parent cff7dbd commit ad269ee

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

fuzz/block_fuzz.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ func (fakeChecker) Resync() error {
9999
return nil
100100
}
101101

102+
// FuzzBlock wraps BeaconFuzzBlock in a go-fuzz compatible interface
103+
func FuzzBlock(b []byte) int {
104+
BeaconFuzzBlock(b)
105+
return 0
106+
}
107+
102108
// BeaconFuzzBlock runs full processing of beacon block against a given state.
103109
func BeaconFuzzBlock(b []byte) {
104110
params.UseMainnetConfig()

fuzz/rpc_status_fuzz.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ func init() {
6262
})
6363
}
6464

65+
// FuzzP2PRPCStatus wraps BeaconFuzzP2PRPCStatus in a go-fuzz compatible interface
66+
func FuzzP2PRPCStatus(b []byte) int {
67+
BeaconFuzzP2PRPCStatus(b)
68+
return 0
69+
}
70+
6571
// BeaconFuzzP2PRPCStatus implements libfuzzer and beacon fuzz interface.
6672
func BeaconFuzzP2PRPCStatus(b []byte) {
6773
s, err := h.NewStream(context.Background(), p.PeerID(), "/eth2/beacon_chain/req/status/1/ssz_snappy")

fuzz/ssz_encoder_attestations_fuzz.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ import (
1010

1111
var buf = new(bytes.Buffer)
1212

13+
// FuzzSszEncoderAttestation wraps SszEncoderAttestationFuzz in a
14+
// go-fuzz compatible interface
15+
func FuzzSszEncoderAttestation(b []byte) int {
16+
SszEncoderAttestationFuzz(b)
17+
return 0
18+
}
19+
1320
// SszEncoderAttestationFuzz runs network encode/decode for attestations.
1421
func SszEncoderAttestationFuzz(b []byte) {
1522
params.UseMainnetConfig()

fuzz/state_fuzz.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ func init() {
1717
})
1818
}
1919

20+
// FuzzState wraps BeaconStateFuzz in a go-fuzz compatible interface
21+
func FuzzState(b []byte) int {
22+
BeaconStateFuzz(b)
23+
return 0
24+
}
25+
2026
// BeaconStateFuzz --
2127
func BeaconStateFuzz(input []byte) {
2228
params.UseMainnetConfig()

fuzzbuzz.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
base:
2+
language: go
3+
docker_image: golang:latest
4+
build_tags:
5+
- libfuzzer
6+
- blst_disabled

0 commit comments

Comments
 (0)