Merge branch 'add_trace_switch' of github.com:jangko/nimbus into jangko-add_trace_switch
This commit is contained in:
commit
2fc238f35f
|
@ -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…
Reference in New Issue