Skip to content

Commit

Permalink
Allow GST to parse new eest devnet-6 test vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Feb 4, 2025
1 parent 1739b8e commit 97b17f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
7 changes: 3 additions & 4 deletions tests/test_config.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2019-2024 Status Research & Development GmbH
# Copyright (c) 2019-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
Expand Down Expand Up @@ -28,15 +28,14 @@ type
index*: Opt[int]
trace*: bool
legacy*: bool
pruning*: bool
subFixture*: Opt[int]
json*: bool

var testConfig {.threadvar.}: Configuration

proc initConfiguration(): Configuration =
result = new Configuration
result.trace = true
result.pruning = true

proc getConfiguration*(): Configuration {.gcsafe.} =
if isNil(testConfig):
Expand All @@ -59,7 +58,7 @@ proc processArguments*(msg: var string): ConfigStatus =
of "index": config.index = Opt.some(parseInt(value))
of "trace": config.trace = parseBool(value)
of "legacy": config.legacy = parseBool(value)
of "pruning": config.pruning = parseBool(value)
of "sub": config.subFixture = Opt.some(parseInt(value))
of "json": config.json = parseBool(value)
else:
msg = "Unknown option " & key
Expand Down
35 changes: 23 additions & 12 deletions tests/test_generalstate_json.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
Expand Down Expand Up @@ -37,6 +37,7 @@ type
debugMode: bool
trace: bool
index: int
subFixture: int
fork: string

var
Expand Down Expand Up @@ -73,7 +74,8 @@ proc dumpDebugData(ctx: TestCtx, vmState: BaseVMState, gasUsed: GasInt, success:
}
let status = if success: "_success" else: "_failed"
let fileName = normalizeFileName(ctx.name)
writeFile(fileName & "_" & ctx.fork & "_" & $ctx.index & status & ".json", debugData.pretty())
writeFile(fileName & "_" & $ctx.subFixture & "_" &
ctx.fork & "_" & $ctx.index & status & ".json", debugData.pretty())

proc testFixtureIndexes(ctx: var TestCtx, testStatusIMPL: var TestStatus) =
let
Expand Down Expand Up @@ -129,15 +131,8 @@ proc testFixtureIndexes(ctx: var TestCtx, testStatusIMPL: var TestStatus) =
let success = ctx.expectedLogs == actualLogsHash and obtainedHash == ctx.expectedHash
ctx.dumpDebugData(vmState, gasUsed, success)

proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
proc testSubFixture(ctx: var TestCtx, fixture: JsonNode, testStatusIMPL: var TestStatus,
trace = false, debugMode = false) =
var ctx: TestCtx
var fixture: JsonNode
for label, child in fixtures:
fixture = child
ctx.name = label
break

ctx.pre = fixture["pre"]
ctx.parent = parseParentHeader(fixture["env"])
ctx.header = parseHeader(fixture["env"])
Expand Down Expand Up @@ -193,12 +188,28 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
runSubTest(subTest)
inc ctx.index

proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
trace = false, debugMode = false) =
let
conf = getConfiguration()

var
ctx: TestCtx
subFixture = 0

for label, child in fixtures:
ctx.name = label
ctx.subFixture = subFixture
inc subFixture
if conf.subFixture.isSome and conf.subFixture.get != ctx.subFixture:
continue
testSubFixture(ctx, child, testStatusIMPL, trace, debugMode)

proc generalStateJsonMain*(debugMode = false) =
const
legacyFolder = "eth_tests/LegacyTests/Constantinople/GeneralStateTests"
newFolder = "eth_tests/GeneralStateTests"
#newFolder = "eth_tests/EIPTests/StateTests"


let config = getConfiguration()
if config.testSubject == "" or not debugMode:
# run all test fixtures
Expand Down

0 comments on commit 97b17f8

Please sign in to comment.