Run t8n test in CI (#2724)

* Enable t8n test to run in CI

* Disable trace test for evmc
This commit is contained in:
andri lim 2024-10-10 20:25:27 +07:00 committed by GitHub
parent 266b72698d
commit 59dde39d95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 12 deletions

View File

@ -210,7 +210,7 @@ jobs:
# give us more space
# find . -type d -name ".git" -exec rm -rf {} +
find . -type d -name "nimcache" -exec rm -rf {} +
mingw32-make ${DEFAULT_MAKE_FLAGS} test
mingw32-make ${DEFAULT_MAKE_FLAGS} test t8n_test
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
mingw32-make ${DEFAULT_MAKE_FLAGS}
fi
@ -228,7 +228,7 @@ jobs:
# ./scripts/launch_local_testnet.sh --nodes=3 --stop-at-epoch=7 \
# --disable-htop --reuse-binaries --run-nimbus-el --dl-eth2 --verbose --kill-old-processes
# popd
env CC=gcc GOARCH=${GOARCH} CXX=g++ CGO_ENABLED=1 make ${DEFAULT_MAKE_FLAGS} test
env CC=gcc GOARCH=${GOARCH} CXX=g++ CGO_ENABLED=1 make ${DEFAULT_MAKE_FLAGS} test t8n_test
- name: Run nimbus-eth1 tests (Macos)
if: runner.os == 'Macos'
@ -243,7 +243,7 @@ jobs:
# ./scripts/launch_local_testnet.sh --nodes=3 --stop-at-epoch=7 \
# --disable-htop --reuse-binaries --run-nimbus-el --dl-eth2 --verbose --kill-old-processes
# popd
make ${DEFAULT_MAKE_FLAGS} test
make ${DEFAULT_MAKE_FLAGS} test t8n_test
lint:
name: "Lint"

View File

@ -175,7 +175,7 @@ ifeq ($(BOEHM_GC),1)
NIM_PARAMS += --mm:boehm
endif
T8N_PARAMS := -d:chronicles_default_output_device=stderr
T8N_PARAMS := -d:chronicles_default_output_device=stderr -d:use_system_rocksdb
ifeq ($(USE_LIBBACKTRACE), 0)
NIM_PARAMS += -d:disable_libbacktrace

View File

@ -57,17 +57,17 @@ proc get(opt: T8nInput, base : string): string =
result.add(" --state.reward " & opt.stReward)
proc get(opt: T8nOutput): string =
if opt.alloc:
if opt.alloc and not opt.trace:
result.add(" --output.alloc stdout")
else:
result.add(" --output.alloc")
if opt.result:
if opt.result and not opt.trace:
result.add(" --output.result stdout")
else:
result.add(" --output.result")
if opt.body:
if opt.body and not opt.trace:
result.add(" --output.body stdout")
else:
result.add(" --output.body")
@ -143,6 +143,14 @@ proc notRejectedError(path: string): bool =
path.endsWith("/error"))
proc runTest(appDir: string, spec: TestSpec): bool =
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
let base = appDir / spec.base
let args = spec.input.get(base) & spec.output.get()
let cmd = appDir / "t8n" & args

View File

@ -173,7 +173,7 @@ proc traceToFileStream(path: string, txIndex: int): Stream =
createDir(file.dir)
newFileStream(fName, fmWrite)
proc setupTrace(conf: T8NConf, txIndex: int, txHash: Hash32, vmState: BaseVMState) =
proc setupTrace(conf: T8NConf, txIndex: int, txHash: Hash32, vmState: BaseVMState): bool =
var tracerFlags = {
TracerFlags.DisableMemory,
TracerFlags.DisableStorage,
@ -186,10 +186,14 @@ proc setupTrace(conf: T8NConf, txIndex: int, txHash: Hash32, vmState: BaseVMStat
if conf.traceNostack: tracerFlags.incl TracerFlags.DisableStack
if conf.traceReturnData: tracerFlags.excl TracerFlags.DisableReturnData
var closeStream = true
let traceMode = conf.traceEnabled.get
let stream = if traceMode == "stdout":
# don't close stdout or stderr
closeStream = false
newFileStream(stdout)
elif traceMode == "stderr":
closeStream = false
newFileStream(stderr)
elif traceMode.len > 0:
traceToFileStream(traceMode, txIndex)
@ -205,10 +209,11 @@ proc setupTrace(conf: T8NConf, txIndex: int, txHash: Hash32, vmState: BaseVMStat
raise newError(ErrorConfig, "Unable to open tracer stream: " & traceLoc)
vmState.tracer = newJsonTracer(stream, tracerFlags, false)
closeStream
proc closeTrace(vmState: BaseVMState) =
proc closeTrace(vmState: BaseVMState, closeStream: bool) =
let tracer = JsonTracer(vmState.tracer)
if tracer.isNil.not:
if tracer.isNil.not and closeStream:
tracer.close()
proc exec(ctx: var TransContext,
@ -264,13 +269,14 @@ proc exec(ctx: var TransContext,
)
continue
var closeStream = true
if conf.traceEnabled.isSome:
setupTrace(conf, txIndex, rlpHash(tx), vmState)
closeStream = setupTrace(conf, txIndex, rlpHash(tx), vmState)
let rc = vmState.processTransaction(tx, sender, header)
if conf.traceEnabled.isSome:
closeTrace(vmState)
closeTrace(vmState, closeStream)
if rc.isErr:
rejected.add RejectedTx(