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