2022-12-10 12:53:24 +00:00
|
|
|
# Nimbus
|
2024-06-24 05:56:24 +00:00
|
|
|
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
2022-12-10 12:53:24 +00:00
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2022-10-15 15:58:23 +00:00
|
|
|
import
|
|
|
|
std/[os, osproc, strutils, json, tables],
|
|
|
|
unittest2,
|
|
|
|
"."/[types]
|
|
|
|
|
|
|
|
type
|
|
|
|
T8nInput = object
|
|
|
|
inAlloc : string
|
|
|
|
inTxs : string
|
|
|
|
inEnv : string
|
|
|
|
stFork : string
|
|
|
|
stReward: string
|
2024-11-08 03:47:07 +00:00
|
|
|
chainid : string
|
2022-10-15 15:58:23 +00:00
|
|
|
|
|
|
|
T8nOutput = object
|
|
|
|
alloc : bool
|
|
|
|
result: bool
|
|
|
|
body : bool
|
2023-08-20 04:15:11 +00:00
|
|
|
trace : bool
|
2022-10-15 15:58:23 +00:00
|
|
|
|
|
|
|
TestSpec = object
|
|
|
|
name : string
|
|
|
|
base : string
|
|
|
|
input : T8nInput
|
|
|
|
output : T8nOutput
|
|
|
|
expExitCode: int
|
|
|
|
expOut : string
|
|
|
|
|
|
|
|
JsonComparator = object
|
|
|
|
path: string
|
|
|
|
error: string
|
|
|
|
|
2024-11-08 03:47:07 +00:00
|
|
|
proc t8nInput(alloc, txs, env, fork: string;
|
|
|
|
reward = "0"; chainid = ""): T8nInput =
|
2022-10-15 15:58:23 +00:00
|
|
|
T8nInput(
|
|
|
|
inAlloc : alloc,
|
|
|
|
inTxs : txs,
|
|
|
|
inEnv : env,
|
|
|
|
stFork : fork,
|
2024-11-08 03:47:07 +00:00
|
|
|
stReward: reward,
|
|
|
|
chainid : chainid,
|
2022-10-15 15:58:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
proc get(opt: T8nInput, base : string): string =
|
|
|
|
result.add(" --input.alloc " & (base / opt.inAlloc))
|
|
|
|
result.add(" --input.txs " & (base / opt.inTxs))
|
|
|
|
result.add(" --input.env " & (base / opt.inEnv))
|
|
|
|
result.add(" --state.fork " & opt.stFork)
|
|
|
|
if opt.stReward.len > 0:
|
|
|
|
result.add(" --state.reward " & opt.stReward)
|
2024-11-08 03:47:07 +00:00
|
|
|
if opt.chainid.len > 0:
|
|
|
|
result.add(" --state.chainid " & opt.chainid)
|
2022-10-15 15:58:23 +00:00
|
|
|
|
|
|
|
proc get(opt: T8nOutput): string =
|
2024-10-10 13:25:27 +00:00
|
|
|
if opt.alloc and not opt.trace:
|
2022-10-15 15:58:23 +00:00
|
|
|
result.add(" --output.alloc stdout")
|
|
|
|
else:
|
|
|
|
result.add(" --output.alloc")
|
|
|
|
|
2024-10-10 13:25:27 +00:00
|
|
|
if opt.result and not opt.trace:
|
2022-10-15 15:58:23 +00:00
|
|
|
result.add(" --output.result stdout")
|
|
|
|
else:
|
|
|
|
result.add(" --output.result")
|
|
|
|
|
2024-10-10 13:25:27 +00:00
|
|
|
if opt.body and not opt.trace:
|
2022-10-15 15:58:23 +00:00
|
|
|
result.add(" --output.body stdout")
|
|
|
|
else:
|
|
|
|
result.add(" --output.body")
|
|
|
|
|
2023-08-20 04:15:11 +00:00
|
|
|
if opt.trace:
|
|
|
|
result.add(" --trace stdout")
|
|
|
|
|
2022-10-15 15:58:23 +00:00
|
|
|
template exit(jsc: var JsonComparator, msg: string) =
|
|
|
|
jsc.path = path
|
|
|
|
jsc.error = msg
|
|
|
|
return false
|
|
|
|
|
|
|
|
proc cmp(jsc: var JsonComparator; a, b: JsonNode, path: string): bool =
|
|
|
|
## Check two nodes for equality
|
|
|
|
if a.isNil:
|
|
|
|
if b.isNil: return true
|
|
|
|
jsc.exit("A nil, but B not nil")
|
|
|
|
elif b.isNil:
|
|
|
|
jsc.exit("A not nil, but B nil")
|
|
|
|
elif a.kind != b.kind:
|
|
|
|
jsc.exit("A($1) != B($2)" % [$a.kind, $b.kind])
|
|
|
|
else:
|
|
|
|
result = true
|
|
|
|
case a.kind
|
|
|
|
of JString:
|
|
|
|
if a.str != b.str:
|
|
|
|
jsc.exit("STRING A($1) != B($2)" % [a.str, b.str])
|
|
|
|
of JInt:
|
|
|
|
if a.num != b.num:
|
|
|
|
jsc.exit("INT A($1) != B($2)" % [$a.num, $b.num])
|
|
|
|
of JFloat:
|
|
|
|
if a.fnum != b.fnum:
|
|
|
|
jsc.exit("FLOAT A($1) != B($2)" % [$a.fnum, $b.fnum])
|
|
|
|
of JBool:
|
|
|
|
if a.bval != b.bval:
|
|
|
|
jsc.exit("BOOL A($1) != B($2)" % [$a.bval, $b.bval])
|
|
|
|
of JNull:
|
|
|
|
result = true
|
|
|
|
of JArray:
|
|
|
|
for i, x in a.elems:
|
|
|
|
if not jsc.cmp(x, b.elems[i], path & "/" & $i):
|
|
|
|
return false
|
|
|
|
of JObject:
|
|
|
|
# we cannot use OrderedTable's equality here as
|
|
|
|
# the order does not matter for equality here.
|
2024-06-30 07:39:45 +00:00
|
|
|
var
|
|
|
|
aFields = newSeqOfCap[string](a.fields.len)
|
|
|
|
bFields = newSeqOfCap[string](b.fields.len)
|
|
|
|
|
2022-10-15 15:58:23 +00:00
|
|
|
for key, val in a.fields:
|
2024-06-30 07:39:45 +00:00
|
|
|
if val.kind != JNull:
|
|
|
|
aFields.add key
|
|
|
|
|
|
|
|
for key, val in b.fields:
|
|
|
|
if val.kind != JNull:
|
|
|
|
bFields.add key
|
|
|
|
|
|
|
|
if aFields.len != bFields.len:
|
|
|
|
jsc.exit("OBJ LEN A($1) != B($2)" % [$aFields.len, $bFields.len])
|
|
|
|
|
|
|
|
for key in aFields:
|
|
|
|
let val = a.fields[key]
|
2022-10-15 15:58:23 +00:00
|
|
|
if not b.fields.hasKey(key):
|
|
|
|
jsc.exit("OBJ FIELD A($1) != B(none)" % [key])
|
|
|
|
if not jsc.cmp(val, b.fields[key], path & "/" & key):
|
|
|
|
return false
|
|
|
|
|
|
|
|
proc notRejectedError(path: string): bool =
|
|
|
|
# we only check error status, and not the error message
|
|
|
|
# because each implementation can have different error
|
|
|
|
# message
|
|
|
|
not (path.startsWith("root/result/rejected/") and
|
|
|
|
path.endsWith("/error"))
|
|
|
|
|
|
|
|
proc runTest(appDir: string, spec: TestSpec): bool =
|
2024-10-10 13:25:27 +00:00
|
|
|
when defined(evmc_enabled):
|
|
|
|
# TODO: test both evm?
|
|
|
|
# skip trace test if evmc_enabled
|
|
|
|
# because the error msg of trace output is
|
|
|
|
# different for nimvm and evmc
|
|
|
|
if spec.output.trace:
|
|
|
|
return true
|
|
|
|
|
2022-10-15 15:58:23 +00:00
|
|
|
let base = appDir / spec.base
|
|
|
|
let args = spec.input.get(base) & spec.output.get()
|
|
|
|
let cmd = appDir / "t8n" & args
|
|
|
|
let (res, exitCode) = execCmdEx(cmd)
|
|
|
|
|
|
|
|
if exitCode != spec.expExitCode:
|
|
|
|
echo "test $1: wrong exit code, have $2, want $3" %
|
|
|
|
[spec.name, $exitCode, $spec.expExitCode]
|
|
|
|
echo res
|
|
|
|
return false
|
|
|
|
|
|
|
|
if spec.expOut.len > 0:
|
2023-08-20 04:15:11 +00:00
|
|
|
if spec.expOut.endsWith(".json"):
|
2024-11-21 14:57:22 +00:00
|
|
|
let path = base / spec.expOut
|
2024-11-08 03:47:07 +00:00
|
|
|
try:
|
|
|
|
let want = json.parseFile(path)
|
|
|
|
let have = json.parseJson(res)
|
|
|
|
var jsc = JsonComparator()
|
|
|
|
if not jsc.cmp(want, have, "root") and notRejectedError(jsc.path):
|
|
|
|
echo "test $1: output wrong, have \n$2\nwant\n$3\n" %
|
|
|
|
[spec.name, have.pretty, want.pretty]
|
|
|
|
echo "path: $1, error: $2" %
|
|
|
|
[jsc.path, jsc.error]
|
|
|
|
return false
|
|
|
|
except JsonParsingError as exc:
|
|
|
|
echo "test $1: ERROR: $2" % [spec.name, exc.msg]
|
|
|
|
echo "test $1: OUTPUT: $2" % [spec.name, res]
|
2023-08-20 04:15:11 +00:00
|
|
|
return false
|
|
|
|
else:
|
|
|
|
# compare as regular text
|
|
|
|
let path = base / spec.expOut
|
|
|
|
let want = readFile(path)
|
|
|
|
if want.replace("\x0D\x0A", "\n") != res:
|
|
|
|
echo "test $1: output wrong, have \n$2\nwant\n$3\n" %
|
|
|
|
[spec.name, res, want]
|
|
|
|
return false
|
2022-10-15 15:58:23 +00:00
|
|
|
return true
|
|
|
|
|
|
|
|
const
|
|
|
|
testSpec = [
|
|
|
|
TestSpec(
|
|
|
|
name : "Test exit (3) on bad config",
|
|
|
|
base : "testdata/1",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Frontier+1346", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expExitCode: ErrorConfig.int,
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "baseline test",
|
|
|
|
base : "testdata/1",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Byzantium", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "blockhash test",
|
|
|
|
base : "testdata/3",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Berlin", ""
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json"
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "missing blockhash test",
|
|
|
|
base : "testdata/4",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Berlin", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expExitCode: ErrorMissingBlockhash.int,
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Uncle test",
|
|
|
|
base : "testdata/5",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Byzantium", "0x80",
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Sign json transactions",
|
|
|
|
base : "testdata/13",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "London", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(body: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Already signed transactions",
|
|
|
|
base : "testdata/13",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "signed_txs.rlp", "env.json", "London", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp2.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Difficulty calculation - no uncles",
|
|
|
|
base : "testdata/14",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "London", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Difficulty calculation - with uncles",
|
|
|
|
base : "testdata/14",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.uncles.json", "London", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp2.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Difficulty calculation - with ommers + Berlin",
|
|
|
|
base : "testdata/14",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.uncles.json", "Berlin", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp_berlin.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
2022-12-02 04:39:12 +00:00
|
|
|
name : "Difficulty calculation on london",
|
2022-10-15 15:58:23 +00:00
|
|
|
base : "testdata/19",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "London", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp_london.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Difficulty calculation on arrow glacier",
|
|
|
|
base : "testdata/19",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "ArrowGlacier", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp_arrowglacier.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Difficulty calculation on gray glacier",
|
|
|
|
base : "testdata/19",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "GrayGlacier", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp_grayglacier.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Sign unprotected (pre-EIP155) transaction",
|
|
|
|
base : "testdata/23",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Berlin", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Test post-merge transition",
|
|
|
|
base : "testdata/24",
|
|
|
|
input : t8nInput(
|
2022-12-02 04:39:12 +00:00
|
|
|
"alloc.json", "txs.json", "env.json", "Merge", "",
|
2022-10-15 15:58:23 +00:00
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Test post-merge transition where input is missing random",
|
|
|
|
base : "testdata/24",
|
|
|
|
input : t8nInput(
|
2022-12-02 04:39:12 +00:00
|
|
|
"alloc.json", "txs.json", "env-missingrandom.json", "Merge", "",
|
2022-10-15 15:58:23 +00:00
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: false, result: false),
|
|
|
|
expExitCode: ErrorConfig.int,
|
|
|
|
),
|
2022-11-23 06:30:05 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "Test state-reward -1",
|
|
|
|
base : "testdata/3",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Berlin", "-1"
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
2022-12-08 02:53:56 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "0-touch reward on pre EIP150 networks -1(txs.rlp)",
|
|
|
|
base : "testdata/00-501",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.rlp", "env.json", "EIP150", "-1"
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "0-touch reward on pre EIP150 networks(txs.rlp)",
|
|
|
|
base : "testdata/00-502",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.rlp", "env.json", "EIP150", ""
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "0-touch reward on pre EIP150 networks(txs.json)",
|
|
|
|
base : "testdata/00-502",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "EIP150", ""
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "calculate basefee from parentBaseFee -1",
|
|
|
|
base : "testdata/00-503",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "London", "-1"
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "calculate basefee from parentBaseFee",
|
|
|
|
base : "testdata/00-504",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "London", ""
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "BLOCKHASH opcode -1",
|
|
|
|
base : "testdata/00-505",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "London", "-1"
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "BLOCKHASH opcode",
|
|
|
|
base : "testdata/00-506",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "London", ""
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
2022-12-15 10:31:47 +00:00
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "testOpcode 40 Berlin",
|
|
|
|
base : "testdata/00-507",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Berlin", "2000000000000000000"
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "suicideCoinbaseState Berlin",
|
|
|
|
base : "testdata/00-508",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Berlin", "2000000000000000000"
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "BLOCKHASH Bounds",
|
|
|
|
base : "testdata/00-509",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Berlin", "2000000000000000000"
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Suicides Mixing Coinbase",
|
|
|
|
base : "testdata/00-510",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Berlin", "2000000000000000000"
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
2023-03-17 13:20:52 +00:00
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Legacy Byzantium State Clearing",
|
|
|
|
base : "testdata/00-511",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.rlp", "env.json", "Byzantium", "-1"
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
2023-03-21 11:36:22 +00:00
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Test withdrawals transition",
|
|
|
|
base : "testdata/26",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Shanghai", ""
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
2023-03-23 02:38:42 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "Revert In Create In Init Create2",
|
|
|
|
base : "testdata/00-512",
|
|
|
|
input : t8nInput(
|
2024-11-21 14:57:22 +00:00
|
|
|
"alloc.json", "txs.rlp", "env.json", "Berlin", "0"
|
2023-03-23 02:38:42 +00:00
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Revert In Create In Init",
|
|
|
|
base : "testdata/00-513",
|
|
|
|
input : t8nInput(
|
2024-11-21 14:57:22 +00:00
|
|
|
"alloc.json", "txs.rlp", "env.json", "Berlin", "0"
|
2023-03-23 02:38:42 +00:00
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Init collision 3",
|
|
|
|
base : "testdata/00-514",
|
|
|
|
input : t8nInput(
|
2024-11-21 14:57:22 +00:00
|
|
|
"alloc.json", "txs.rlp", "env.json", "Berlin", "0"
|
2023-03-23 02:38:42 +00:00
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
2023-04-11 03:43:36 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "Malicious withdrawals address",
|
|
|
|
base : "testdata/00-515",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Shanghai", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: false, result: false),
|
|
|
|
expExitCode: ErrorJson.int,
|
|
|
|
),
|
2023-04-11 08:28:45 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "GasUsedHigherThanBlockGasLimitButNotWithRefundsSuicideLast_Frontier",
|
|
|
|
base : "testdata/00-516",
|
|
|
|
input : t8nInput(
|
2024-11-21 14:57:22 +00:00
|
|
|
"alloc.json", "txs.rlp", "env.json", "Frontier", "5000000000000000000"
|
2023-04-11 08:28:45 +00:00
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
2023-06-24 13:56:44 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "Cancun optional fields",
|
|
|
|
base : "testdata/00-517",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Cancun", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
2023-07-20 13:20:41 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "Blobhash list bounds",
|
|
|
|
base : "testdata/00-518",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Cancun", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
2023-08-20 04:15:11 +00:00
|
|
|
TestSpec(
|
2023-08-23 09:29:33 +00:00
|
|
|
name : "EVM tracer nil stack crash bug",
|
2023-08-20 04:15:11 +00:00
|
|
|
base : "testdata/00-519",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Shanghai", "0",
|
|
|
|
),
|
|
|
|
output: T8nOutput(trace: true),
|
|
|
|
expOut: "exp.txt",
|
|
|
|
),
|
2023-08-23 09:29:33 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "EVM tracer wrong order for CALL family opcodes",
|
|
|
|
base : "testdata/00-520",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Merge", "0",
|
|
|
|
),
|
|
|
|
output: T8nOutput(trace: true, result: true),
|
|
|
|
expOut: "exp.txt",
|
|
|
|
),
|
2023-08-27 06:13:37 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "EVM tracer CALL family exception",
|
|
|
|
base : "testdata/00-521",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Shanghai", "0",
|
|
|
|
),
|
|
|
|
output: T8nOutput(trace: true, result: true),
|
|
|
|
expOut: "exp.txt",
|
|
|
|
),
|
2023-08-30 16:29:48 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "Cancun tests",
|
|
|
|
base : "testdata/28",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.rlp", "env.json", "Cancun", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "More cancun tests",
|
|
|
|
base : "/testdata/29",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Cancun", "",
|
|
|
|
),
|
|
|
|
output: T8nOutput(alloc: true, result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
2023-08-31 02:49:51 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "Trace EIP-2929 Balance, Sload, ExtCodeSize, ExtCodeHash",
|
|
|
|
base : "testdata/00-522",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Berlin", "0",
|
|
|
|
),
|
|
|
|
output: T8nOutput(trace: true, result: true),
|
|
|
|
expOut: "exp.txt",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Trace Post EIP-2929 Balance, Sload, ExtCodeSize, ExtCodeHash",
|
|
|
|
base : "testdata/00-522",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "London", "0",
|
|
|
|
),
|
|
|
|
output: T8nOutput(trace: true, result: true),
|
|
|
|
expOut: "exp.txt",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Trace Pre EIP-2929 Balance, Sload, ExtCodeSize, ExtCodeHash",
|
|
|
|
base : "testdata/00-522",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.json", "env.json", "Istanbul", "0",
|
|
|
|
),
|
|
|
|
output: T8nOutput(trace: true, result: true),
|
|
|
|
expOut: "istanbul.txt",
|
|
|
|
),
|
2024-06-24 05:56:24 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "Blob gas used exceeds max allowance",
|
|
|
|
base : "testdata/00-523",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.rlp", "env.json", "Cancun", "0",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
2024-06-30 07:39:45 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "Calculate excessBlobGas if not supplied",
|
|
|
|
base : "testdata/00-524",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.rlp", "env.json", "Cancun", "0",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp.json",
|
|
|
|
),
|
2024-11-08 03:47:07 +00:00
|
|
|
TestSpec(
|
|
|
|
name : "Different --state.chainid and tx.chainid",
|
|
|
|
base : "testdata/00-525",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.rlp", "env.json", "Prague",
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp1.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Prague execution requests",
|
|
|
|
base : "testdata/00-525",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.rlp", "env.json", "Prague", "", "7078815900"
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp2.json",
|
|
|
|
),
|
|
|
|
TestSpec(
|
|
|
|
name : "Prague depositContractAddress",
|
|
|
|
base : "testdata/00-525",
|
|
|
|
input : t8nInput(
|
|
|
|
"alloc.json", "txs.rlp", "env_dca.json", "Prague", "", "7078815900"
|
|
|
|
),
|
|
|
|
output: T8nOutput(result: true),
|
|
|
|
expOut: "exp3.json",
|
|
|
|
),
|
2022-10-15 15:58:23 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
proc main() =
|
|
|
|
suite "Transition tool (t8n) test suite":
|
|
|
|
let appDir = getAppDir()
|
|
|
|
for x in testSpec:
|
|
|
|
test x.name:
|
|
|
|
check runTest(appDir, x)
|
|
|
|
|
|
|
|
when isMainModule:
|
|
|
|
main()
|