Add a fuzzing test for the beacon node CLI parser

This commit is contained in:
Zahary Karadjov 2020-10-01 22:08:59 +03:00 committed by zah
parent c5a58555ef
commit f5340998b9
13 changed files with 54 additions and 9 deletions

View File

@ -3,13 +3,13 @@
import
os, options,
chronicles, chronicles/options as chroniclesOptions,
confutils, confutils/defs, confutils/std/net,
confutils, confutils/defs, confutils/std/net, stew/shims/net as stewNet,
json_serialization, web3/[ethtypes, confutils_defs],
network_metadata, spec/[crypto, keystore, digest, datatypes]
spec/[crypto, keystore, digest, datatypes, network], network_metadata
export
defs, enabledLogLevel, parseCmdArg, completeCmdArg,
network_metadata
defaultEth2TcpPort, enabledLogLevel, ValidIpAddress,
defs, parseCmdArg, completeCmdArg, network_metadata
type
ValidatorKeyPath* = TypedInputFile[ValidatorPrivKey, Txt, "privkey"]
@ -238,7 +238,7 @@ type
name: "last-user-validator" }: uint64
bootstrapAddress* {.
defaultValue: ValidIpAddress.init("127.0.0.1")
defaultValue: init(ValidIpAddress, "127.0.0.1")
desc: "The public IP address that will be advertised as a bootstrap node for the testnet"
name: "bootstrap-address" }: ValidIpAddress

View File

@ -0,0 +1,29 @@
import os except dirExists
import
sequtils, strformat,
confutils, testutils/fuzzing_engines
const
gitRoot = thisDir() / ".."
fuzzingTestsDir = gitRoot / "tests" / "fuzzing"
cli do (testname {.argument.}: string,
fuzzer = defaultFuzzingEngine):
let fuzzingTestDir = fuzzingTestsDir / testname
if not dirExists(fuzzingTestDir):
echo "Cannot find a fuzz test directory named '", testname, "' in ", fuzzingTestsDir
quit 1
let nimFiles = listFiles(fuzzingTestDir).filterIt(splitFile(it).ext == ".nim")
if nimFiles.len != 1:
echo "The fuzzing test dir '" & fuzzingTestDir & "' should contain exactly one Nim file"
quit 1
let
corpusDir = fuzzingTestDir / "corpus"
testProgram = nimFiles[0]
exec &"""ntu fuzz --fuzzer={fuzzer} --corpus="{corpusDir}" "{testProgram}" """

View File

@ -9,8 +9,6 @@ const
fuzzingTestsDir = gitRoot / "tests" / "fuzzing"
fuzzingCorpusesDir = fuzzingTestsDir / "corpus"
fuzzNims = gitRoot / "vendor" / "nim-testutils" / "testutils" / "fuzzing" / "fuzz.nims"
cli do (testname {.argument.}: string,
fuzzer = defaultFuzzingEngine):

View File

@ -0,0 +1 @@
--help

View File

@ -0,0 +1 @@
deposits create --network=spadina --new-wallet-file=build/data/shared_spadina_0/wallet.json --out-validators-dir=build/data/shared_spadina_0/validators --out-secrets-dir=build/data/shared_spadina_0/secrets --out-deposits-file=spadina-deposits_data-20201001212925.json --count=1

View File

@ -0,0 +1 @@
--network=spadina --log-level=INFO --log-file=build/data/shared_spadina_0/nbc_bn_20201001212647.log --data-dir=build/data/shared_spadina_0 --web3-url=wss://goerli.infura.io/ws/v3/809a18497dd74102b5f37d25aae3c85a --tcp-port=9000 --udp-port=9000 --metrics --metrics-port=8008 --rpc --rpc-port=9190

View File

@ -0,0 +1 @@
--version

View File

@ -0,0 +1 @@
wallets create --name:"my wallet" --next-account:10 --out:/tmp/wallet.json

View File

@ -0,0 +1 @@
wallets restore --name:"some wallet name" --deposits:10 --out:"some wallet name.json"

View File

@ -0,0 +1,10 @@
import
# TODO These imports shouldn't be necessary here
# (this is a variation of the sandwich problem)
stew/shims/net, chronicles,
confutils/cli_parsing_fuzzer,
../../../beacon_chain/conf, ../../../beacon_chain/spec/network
fuzzCliParsing BeaconNodeConf

View File

@ -1,3 +1,5 @@
# clang complains that -flto=auto is not a supported option when creating libFuzzer builds
-d:disableLTO
-d:ssz_testing
-d:"const_preset=mainnet"

@ -1 +1 @@
Subproject commit 2e8040ec5e6e5416846e008b4d455bd026394fb0
Subproject commit 5c81aab54d00bb4cc0921fc9d3ace828b1fcc09f

@ -1 +1 @@
Subproject commit 61e5e1ec817cc73fc43585acae4def287180e78e
Subproject commit cc5d6e46123e0cf5dfd14f5fc32f0d6f58a20645