2020-07-10 23:28:53 +00:00
|
|
|
import
|
2020-07-20 15:09:15 +00:00
|
|
|
std/[os, strutils, options],
|
2020-07-10 23:28:53 +00:00
|
|
|
stew/shims/net,
|
2020-07-20 15:09:15 +00:00
|
|
|
eth/keys, eth/p2p/discoveryv5/enr,
|
|
|
|
../fuzzing_helpers
|
2020-07-10 23:28:53 +00:00
|
|
|
|
|
|
|
template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0]
|
|
|
|
const inputsDir = sourceDir / "corpus"
|
|
|
|
|
|
|
|
proc generate() =
|
|
|
|
let
|
|
|
|
rng = newRng()
|
|
|
|
privKey = PrivateKey.random(rng[])
|
|
|
|
ip = some(ValidIpAddress.init("127.0.0.1"))
|
|
|
|
port = Port(20301)
|
|
|
|
|
|
|
|
block:
|
|
|
|
let record = enr.Record.init(1, privKey, ip, port, port)[]
|
|
|
|
record.raw.toFile(inputsDir / "enr1")
|
|
|
|
block:
|
|
|
|
let record = enr.Record.init(1, privKey, ip, port, port, [toFieldPair("test", 1'u)])[]
|
|
|
|
record.raw.toFile(inputsDir / "enr2")
|
|
|
|
|
|
|
|
discard existsOrCreateDir(inputsDir)
|
|
|
|
generate()
|