mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-02 01:36:06 +00:00
Add a fuzzing test for the beacon node CLI parser
This commit is contained in:
parent
c5a58555ef
commit
f5340998b9
@ -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
|
||||
|
||||
|
29
scripts/run_fuzzing_test.nims
Normal file
29
scripts/run_fuzzing_test.nims
Normal 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}" """
|
||||
|
@ -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):
|
||||
|
||||
|
1
tests/fuzzing/beacon_node_cli/corpus/help.txt
Normal file
1
tests/fuzzing/beacon_node_cli/corpus/help.txt
Normal file
@ -0,0 +1 @@
|
||||
--help
|
@ -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
|
1
tests/fuzzing/beacon_node_cli/corpus/spadina.txt
Normal file
1
tests/fuzzing/beacon_node_cli/corpus/spadina.txt
Normal 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
|
1
tests/fuzzing/beacon_node_cli/corpus/version.txt
Normal file
1
tests/fuzzing/beacon_node_cli/corpus/version.txt
Normal file
@ -0,0 +1 @@
|
||||
--version
|
1
tests/fuzzing/beacon_node_cli/corpus/wallets-create.txt
Normal file
1
tests/fuzzing/beacon_node_cli/corpus/wallets-create.txt
Normal file
@ -0,0 +1 @@
|
||||
wallets create --name:"my wallet" --next-account:10 --out:/tmp/wallet.json
|
1
tests/fuzzing/beacon_node_cli/corpus/wallets-restore.txt
Normal file
1
tests/fuzzing/beacon_node_cli/corpus/wallets-restore.txt
Normal file
@ -0,0 +1 @@
|
||||
wallets restore --name:"some wallet name" --deposits:10 --out:"some wallet name.json"
|
10
tests/fuzzing/beacon_node_cli/fuzz_beacon_node_cli.nim
Normal file
10
tests/fuzzing/beacon_node_cli/fuzz_beacon_node_cli.nim
Normal 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
|
||||
|
@ -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"
|
||||
|
||||
|
2
vendor/nim-confutils
vendored
2
vendor/nim-confutils
vendored
@ -1 +1 @@
|
||||
Subproject commit 2e8040ec5e6e5416846e008b4d455bd026394fb0
|
||||
Subproject commit 5c81aab54d00bb4cc0921fc9d3ace828b1fcc09f
|
2
vendor/nim-testutils
vendored
2
vendor/nim-testutils
vendored
@ -1 +1 @@
|
||||
Subproject commit 61e5e1ec817cc73fc43585acae4def287180e78e
|
||||
Subproject commit cc5d6e46123e0cf5dfd14f5fc32f0d6f58a20645
|
Loading…
x
Reference in New Issue
Block a user