fix bc/gst tester for istanbul [skip ci]

This commit is contained in:
andri lim 2019-11-13 18:39:35 +07:00
parent d01edfdcac
commit f66f49168a
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 22 additions and 11 deletions

View File

@ -53,11 +53,6 @@ proc fromJson*(n: JsonNode, name: string, x: var Blob) =
proc fromJson*(n: JsonNode, name: string, x: var UInt256) =
x = UInt256.fromHex(n[name].getStr())
if x.prefixHex != toLowerAscii(n[name].getStr()):
debugEcho "name: ", name
debugEcho "A: ", x.prefixHex
debugEcho "B: ", toLowerAscii(n[name].getStr())
quit(1)
doAssert(x.prefixHex == toLowerAscii(n[name].getStr()), name)
proc fromJson*(n: JsonNode, name: string, x: var SomeInteger) =

View File

@ -72,11 +72,14 @@ func normalizeNumber(n: JsonNode): JsonNode =
let str = n.getStr
# paranoid checks
doAssert n.kind == Jstring
doAssert str.len > 3
doAssert str[0] == '0' and str[1] == 'x'
# real normalization
# strip leading 0
if str == "0x00":
if str == "0x":
result = newJString("0x0")
elif str == "0x0":
result = n
elif str == "0x00":
result = newJString("0x0")
elif str[2] == '0':
var i = 2
@ -197,6 +200,7 @@ func vmConfiguration(network: string): VMConfig =
of "HomesteadToEIP150At5": result = [(0, FkHomestead), (5, FkTangerine)]
of "FrontierToHomesteadAt5": result = [(0, FkFrontier), (5, FkHomestead)]
of "ByzantiumToConstantinopleFixAt5": result = [(0, FkByzantium), (5, FkConstantinople)]
of "Istanbul": result = [(0, FkIstanbul), (0, FkIstanbul)]
else:
raise newException(ValueError, "unsupported network")
@ -279,7 +283,7 @@ proc processBlock(vmState: BaseVMState, minedBlock: PlainBlock, fork: Fork) =
vmState.receipts[txIndex] = makeReceipt(vmState, fork)
if vmState.cumulativeGasUsed != minedBlock.header.gasUsed:
raise newException(ValidationError, "wrong gas used in header")
raise newException(ValidationError, &"wrong gas used in header expected={minedBlock.header.gasUsed}, actual={vmState.cumulativeGasUsed}")
assignBlockRewards(minedBlock, vmState, fork, vmState.chainDB)
@ -663,6 +667,8 @@ proc main() =
# run all test fixtures
suite "block chain json tests":
jsonTest("BlockchainTests", testFixture)
suite "new block chain json tests":
jsonTest("NewBlockchainTests", testFixture)
else:
# execute single test in debug mode
let config = getConfiguration()
@ -670,7 +676,7 @@ proc main() =
echo "missing test subject"
quit(QuitFailure)
let path = "tests" / "fixtures" / "BlockChainTests"
let path = "tests" / "fixtures" / "NewBlockChainTests"
let n = json.parseFile(path / config.testSubject)
var testStatusIMPL: TestStatus
testFixture(n, testStatusIMPL, debugMode = true, config.trace)

View File

@ -176,6 +176,8 @@ proc generalStateJsonMain*(debugMode = false) =
# run all test fixtures
suite "generalstate json tests":
jsonTest("GeneralStateTests", testFixture)
suite "new generalstate json tests":
jsonTest("NewGeneralStateTests", testFixture)
else:
# execute single test in debug mode
let config = getConfiguration()

View File

@ -26,10 +26,18 @@ const
FkTangerine: "EIP150",
FkSpurious: "EIP158",
FkByzantium: "Byzantium",
FkConstantinople: "ConstantinopleFix"
FkConstantinople: "ConstantinopleFix",
FkIstanbul: "Istanbul"
}.toTable
supportedForks* = {FkFrontier, FkHomestead, FkTangerine, FkSpurious, FkByzantium, FkConstantinople}
supportedForks* = {
FkFrontier,
FkHomestead,
FkTangerine,
FkSpurious,
FkByzantium,
FkConstantinople,
FkIstanbul}
nameToFork* = revmap(forkNames)