mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 13:24:21 +00:00
add 'trace' switch to tester configuration
This commit is contained in:
parent
7d9aa54b2c
commit
e05108b7e4
@ -16,6 +16,7 @@ type
|
||||
testSubject*: string
|
||||
fork*: Fork
|
||||
index*: int
|
||||
trace*: bool
|
||||
|
||||
var testConfig {.threadvar.}: Configuration
|
||||
|
||||
@ -23,6 +24,7 @@ proc initConfiguration(): Configuration =
|
||||
result = new Configuration
|
||||
result.fork = FkFrontier
|
||||
result.index = 0
|
||||
result.trace = true
|
||||
|
||||
proc getConfiguration*(): Configuration {.gcsafe.} =
|
||||
if isNil(testConfig):
|
||||
@ -43,6 +45,7 @@ proc processArguments*(msg: var string): ConfigStatus =
|
||||
case key.toLowerAscii()
|
||||
of "fork": config.fork = parseEnum[Fork](strip(value))
|
||||
of "index": config.index = parseInt(value)
|
||||
of "trace": config.trace = parseBool(value)
|
||||
else:
|
||||
msg = "Unknown option " & key
|
||||
if value.len > 0: msg = msg & " : " & value
|
||||
|
@ -25,6 +25,7 @@ type
|
||||
expectedLogs: string
|
||||
fork: Fork
|
||||
debugMode: bool
|
||||
trace: bool
|
||||
index: int
|
||||
|
||||
GST_VMState = ref object of BaseVMState
|
||||
@ -74,16 +75,17 @@ proc dumpDebugData(tester: Tester, vmState: BaseVMState, sender: EthAddress, gas
|
||||
accounts[$account] = dumpAccount(vmState.readOnlyStateDB, account, "pre" & $i)
|
||||
inc i
|
||||
|
||||
let tracingResult = if tester.trace: vmState.getTracingResult() else: %[]
|
||||
let debugData = %{
|
||||
"gasUsed": %gasUsed,
|
||||
"structLogs": vmState.getTracingResult(),
|
||||
"structLogs": tracingResult,
|
||||
"accounts": accounts
|
||||
}
|
||||
let status = if success: "_success" else: "_failed"
|
||||
writeFile("debug_" & tester.name & "_" & $tester.index & status & ".json", debugData.pretty())
|
||||
|
||||
proc testFixtureIndexes(tester: Tester, testStatusIMPL: var TestStatus) =
|
||||
var tracerFlags: set[TracerFlags] = if tester.debugMode: {TracerFlags.EnableTracing} else : {}
|
||||
var tracerFlags: set[TracerFlags] = if tester.trace: {TracerFlags.EnableTracing} else : {}
|
||||
var vmState = newGST_VMState(emptyRlpHash, tester.header, newBaseChainDB(newMemoryDb()), tracerFlags)
|
||||
var gasUsed: GasInt
|
||||
let sender = tester.tx.getSender()
|
||||
@ -125,7 +127,7 @@ proc testFixtureIndexes(tester: Tester, testStatusIMPL: var TestStatus) =
|
||||
gasUsed = tester.tx.processTransaction(sender, vmState, tester.fork)
|
||||
|
||||
proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
|
||||
debugMode = false, supportedForks: set[Fork] = supportedForks) =
|
||||
trace = false, debugMode = false, supportedForks: set[Fork] = supportedForks) =
|
||||
var tester: Tester
|
||||
var fixture: JsonNode
|
||||
for label, child in fixtures:
|
||||
@ -144,6 +146,7 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
|
||||
)
|
||||
|
||||
let specifyIndex = getConfiguration().index
|
||||
tester.trace = trace
|
||||
tester.debugMode = debugMode
|
||||
let ftrans = fixture["transaction"]
|
||||
var testedInFork = false
|
||||
@ -186,7 +189,7 @@ proc main() =
|
||||
var testStatusIMPL: TestStatus
|
||||
var forks: set[Fork] = {}
|
||||
forks.incl config.fork
|
||||
testFixture(n, testStatusIMPL, true, forks)
|
||||
testFixture(n, testStatusIMPL, config.trace, true, forks)
|
||||
|
||||
when isMainModule:
|
||||
var message: string
|
||||
|
Loading…
x
Reference in New Issue
Block a user