Skip to content

Commit

Permalink
go/storage/mkvs: Fuzz node unmarshaller
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Feb 24, 2020
1 parent dddddc0 commit 0421744
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions go/.codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ ignore:
- "oasis-test-runner" # E2E test runner.
- "oasis-net-runner" # Test local network runner.
- "staking/gen_vectors" # Staking test vector generator.
- "storage/fuzz" # Fuzz tests.
- "storage/mkvs/urkel/fuzz" # Fuzz tests.
- "consensus/tendermint/fuzz" # Fuzz tests.
5 changes: 4 additions & 1 deletion go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ integrationrunner:
fuzz-targets := fuzz-consensus \
fuzz-storage \
fuzz-mkvs/Tree \
fuzz-mkvs/Proof
fuzz-mkvs/Proof \
fuzz-mkvs/Node

define canned-fuzz-run
@TARGETDIR=$(shell pwd)/$<; \
Expand Down Expand Up @@ -111,6 +112,8 @@ fuzz-mkvs/Tree: storage/mkvs/urkel/fuzz
$(canned-fuzz-run)
fuzz-mkvs/Proof: storage/mkvs/urkel/fuzz
$(canned-fuzz-run)
fuzz-mkvs/Node: storage/mkvs/urkel/fuzz
$(canned-fuzz-run)

# Target that only builds all fuzzing infrastructure.
build-fuzz: FUZZ_BUILD_ONLY=1
Expand Down
18 changes: 18 additions & 0 deletions go/storage/mkvs/urkel/fuzz/node.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// +build gofuzz

package fuzz

import "github.com/oasislabs/oasis-core/go/storage/mkvs/urkel/node"

func FuzzNode(data []byte) int {
n, err := node.UnmarshalBinary(data)
if err != nil {
return 0
}

_, err = n.CompactMarshalBinary()
if err != nil {
panic(err)
}
return 1
}

0 comments on commit 0421744

Please sign in to comment.