skip 1000+ tests which either are slow (quadratic tests) or don't support Homestead; add ~50 new working tests (#143)

This commit is contained in:
Dustin Brody 2018-09-12 16:33:53 +00:00 committed by GitHub
parent 62260c786d
commit 3cc7e9d8fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1104 additions and 1089 deletions

File diff suppressed because it is too large Load Diff

View File

@ -83,7 +83,6 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
options = newMessageOptions(origin = sender,
createAddress = transaction.to))
# build_computation (Py-EVM)
var computation = newBaseComputation(vmState, header.blockNumber, message)
computation.vmState = vmState
@ -95,7 +94,6 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
try:
computation.executeOpcodes()
# finalize_computation (Py-EVM)
let
gasRemaining = computation.gasMeter.gasRemaining
gasRefunded = computation.gasMeter.gasRefunded
@ -105,12 +103,12 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
vmState.mutateStateDB:
db.setBalance(currentCoinbase, db.getBalance(currentCoinbase) - gasRefundAmount.u256)
db.deltaBalance(sender, gasRefundAmount.u256)
db.deltaBalance(transaction.to, transaction.value)
db.setBalance(sender, db.getBalance(sender) - transaction.value)
db.deltaBalance(sender, gasRefundAmount.u256)
except ValueError:
echo "Computation error"
# TODO: do this right
doAssert "0x" & `$`(vmState.readOnlyStateDB.rootHash).toLowerAscii == fixture["post"]["Byzantium"][0]["hash"].getStr
doAssert "0x" & `$`(vmState.readOnlyStateDB.rootHash).toLowerAscii == fixture["post"]["Homestead"][0]["hash"].getStr

View File

@ -18,7 +18,8 @@ type
func slowTest*(folder: string, name: string): bool =
# TODO: add vmPerformance and loop check here
result = name in @["randomStatetest352.json", "randomStatetest1.json",
result = folder == "stQuadraticComplexityTest" or
name in @["randomStatetest352.json", "randomStatetest1.json",
"randomStatetest32.json", "randomStatetest347.json",
"randomStatetest393.json", "randomStatetest626.json",
"CALLCODE_Bounds.json", "DELEGATECALL_Bounds3.json",
@ -37,6 +38,22 @@ func validTest*(folder: string, name: string): bool =
name notin @["static_Call1024BalanceTooLow.json",
"Call1024BalanceTooLow.json", "ExtCodeCopyTests.json"])
proc lacksHomesteadPostStates*(filename: string): bool =
# XXX: Until Nimbus supports Byzantine or newer forks, as opposed
# to Homestead, ~1k of ~2.5k GeneralStateTests won't work. Nimbus
# supporting Byzantine should trigger removal of this function. A
# possible alternate approach of avoiding double-reading fixtures
# seemed less than ideal, as by the time that happens, output has
# already appeared. Compatible with non-GST fixtures. Will become
# expensive once BlockchainTests appear, so try to remove first.
let fixtures = parseJSON(readFile(filename))
var fixture: JsonNode
for label, child in fixtures:
fixture = child
break
return fixture.has_key("transaction") and not fixture["post"].has_key("Homestead")
macro jsonTest*(s: static[string], handler: untyped): untyped =
let
testStatusIMPL = ident("testStatusIMPL")
@ -55,7 +72,7 @@ macro jsonTest*(s: static[string], handler: untyped): untyped =
if not status.hasKey(last):
status[last] = initOrderedTable[string, Status]()
status[last][name] = Status.Skip
if last.validTest(name):
if last.validTest(name) and not filename.lacksHomesteadPostStates:
filenames.add((filename, last, name))
for child in filenames:
let (filename, folder, name) = child