2020-07-10 23:28:53 +00:00
|
|
|
import
|
2024-06-27 13:15:23 +00:00
|
|
|
std/[os, strutils, net],
|
2021-09-07 14:00:01 +00:00
|
|
|
../../../eth/keys, ../../../eth/p2p/discoveryv5/enr,
|
2020-07-20 15:09:15 +00:00
|
|
|
../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[])
|
2024-06-18 16:09:27 +00:00
|
|
|
ip = Opt.some(parseIpAddress("127.0.0.1"))
|
|
|
|
port = Opt.some(Port(20301))
|
2020-07-10 23:28:53 +00:00
|
|
|
|
|
|
|
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()
|