mirror of
https://github.com/status-im/nim-codex.git
synced 2025-01-10 02:45:59 +00:00
92a0eda79a
* adds a new overload of queryPastEvents allowing to query past events based on timestamp in the past * adds state restoration to validator * refactors a bit to get the tests back to work * replaces deprecated generic methods from Market with methods for specific event types * Refactors binary search * adds market tests for querying past SlotFilled events and binary search * Takes into account that <<earliest>> block available is not necessarily the genesis block * Adds more logging and makes testing earliest block boundary more reliable * adds validation tests for historical state restoration * adds mockprovider to simplify and improve testing of the edge conditions * adds slot reservation to the new tests after rebasing * adds validation groups and group index in logs of validator * adds integration test with two validators * adds comment on how to enable logging in integration test executable itself * testIntegration: makes list is running nodes injected and available in the body of the test * validation: adds integration test for historical state * adds more logging to validator * integration test: validator only looks 30 days back for historical state * adds logging of the slotState when removing slots during validation * review and refactor validator integration tests * adds validation to the set of integration tests * Fixes mistyped name of the mock provider module in testMarket * Fixes a typo in the name of the validation suite in integration tests * Makes validation unit test a bit easier to follow * better use of logScopes to reduce duplication * improves timing and clarifies the test conditions * uses http as default RPC provider for nodes running in integration tests as a workaround for dropped subscriptions * simplifies the validation integration tests by waiting for failed request instead of tracking slots * adds config option allowing selectively to set different provider url * Brings back the default settings for RPC provider in integration tests * use http RPC provider for clients in validation integration tests * fine-tune the tests * Makes validator integration test more robust - adds extra tracking * brings tracking of marketplace event back to validator integration test * refactors integration tests * deletes tmp file * adds <<return>> after forcing integration test to fail preliminarily * re-enables all integration tests and matrix * stops debug output in CI * allows to choose a different RPC provider for a given integration test suite * fixes signature of <<getBlock>> method in mockProvider * adds missing import which seem to be braking integration tests on windows * makes sure that clients, SPs, and validators use the same provider url * makes validator integration tests using http at 127.0.0.1:8545 * testvalidator: stop resubscribing as we are now using http polling as rpc provider * applying review comments * groups queryPastStorage overrides together (review comment) * groups the historical validation tests into a sub suite * removes the temporary extensions in marketplacesuite and multinodesuite allowing to specify provider url * simplifies validation integration tests * Removes debug logs when waiting for request to fail * Renaming waitForRequestFailed => waitForRequestToFail * renames blockNumberForBlocksAgo to pastBlockTag and makes it private * removes redundant debugging logs * refines logging in validation * removes dev logging from mockmarket * improves exception handling in provider helper procs and prepares for extraction to a separate module * Uses chronos instead of std/times for Duration * extracts provider and binary search helpers to a separate module * removes redundant log entry params from validator * unifies the notation to consistently use method call syntax * reuses ProviderError from nim-ethers in the provider extension * clarifies the comment in multinodesuite * uses == operator to check the predefined tags and raises exception when `BlockTag.pending` is requested. * when waiting for request to fail, we break on any request state that is not Started * removes tests that were moved to testProvider from testMarket * extracts tests that use MockProvider to a separate async suite * improves performance of the historical state restoration * removing redundant log messages in validator (groupIndex and groups) * adds testProvider to testContracts group * removes unused import in testMarket
108 lines
4.0 KiB
Nim
108 lines
4.0 KiB
Nim
mode = ScriptMode.Verbose
|
|
|
|
import std/os except commandLineParams
|
|
|
|
### Helper functions
|
|
proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
|
|
if not dirExists "build":
|
|
mkDir "build"
|
|
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
|
|
var extra_params = params
|
|
when compiles(commandLineParams):
|
|
for param in commandLineParams():
|
|
extra_params &= " " & param
|
|
else:
|
|
for i in 2..<paramCount():
|
|
extra_params &= " " & paramStr(i)
|
|
|
|
let
|
|
# Place build output in 'build' folder, even if name includes a longer path.
|
|
outName = os.lastPathPart(name)
|
|
cmd = "nim " & lang & " --out:build/" & outName & " " & extra_params & " " & srcDir & name & ".nim"
|
|
|
|
exec(cmd)
|
|
|
|
proc test(name: string, srcDir = "tests/", params = "", lang = "c") =
|
|
buildBinary name, srcDir, params
|
|
exec "build/" & name
|
|
|
|
task codex, "build codex binary":
|
|
buildBinary "codex", params = "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE"
|
|
|
|
task toolsCirdl, "build tools/cirdl binary":
|
|
buildBinary "tools/cirdl/cirdl"
|
|
|
|
task testCodex, "Build & run Codex tests":
|
|
test "testCodex", params = "-d:codex_enable_proof_failures=true"
|
|
|
|
task testContracts, "Build & run Codex Contract tests":
|
|
test "testContracts"
|
|
|
|
task testIntegration, "Run integration tests":
|
|
buildBinary "codex", params = "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE -d:codex_enable_proof_failures=true"
|
|
test "testIntegration"
|
|
# use params to enable logging from the integration test executable
|
|
# test "testIntegration", params = "-d:chronicles_sinks=textlines[notimestamps,stdout],textlines[dynamic] " &
|
|
# "-d:chronicles_enabled_topics:integration:TRACE"
|
|
|
|
task build, "build codex binary":
|
|
codexTask()
|
|
|
|
task test, "Run tests":
|
|
testCodexTask()
|
|
|
|
task testTools, "Run Tools tests":
|
|
toolsCirdlTask()
|
|
test "testTools"
|
|
|
|
task testAll, "Run all tests (except for Taiko L2 tests)":
|
|
testCodexTask()
|
|
testContractsTask()
|
|
testIntegrationTask()
|
|
testToolsTask()
|
|
|
|
task testTaiko, "Run Taiko L2 tests":
|
|
codexTask()
|
|
test "testTaiko"
|
|
|
|
import strutils
|
|
import os
|
|
|
|
task coverage, "generates code coverage report":
|
|
var (output, exitCode) = gorgeEx("which lcov")
|
|
if exitCode != 0:
|
|
echo " ************************** ⛔️ ERROR ⛔️ **************************"
|
|
echo " ** ERROR: lcov not found, it must be installed to run code **"
|
|
echo " ** coverage locally **"
|
|
echo " *****************************************************************"
|
|
quit 1
|
|
|
|
(output, exitCode) = gorgeEx("gcov --version")
|
|
if output.contains("Apple LLVM"):
|
|
echo " ************************* ⚠️ WARNING ⚠️ *************************"
|
|
echo " ** WARNING: Using Apple's llvm-cov in place of gcov, which **"
|
|
echo " ** emulates an old version of gcov (4.2.0) and therefore **"
|
|
echo " ** coverage results will differ than those on CI (which **"
|
|
echo " ** uses a much newer version of gcov). **"
|
|
echo " *****************************************************************"
|
|
|
|
var nimSrcs = " "
|
|
for f in walkDirRec("codex", {pcFile}):
|
|
if f.endswith(".nim"): nimSrcs.add " " & f.absolutePath.quoteShell()
|
|
|
|
echo "======== Running Tests ======== "
|
|
test "coverage", srcDir = "tests/", params = " --nimcache:nimcache/coverage -d:release -d:codex_enable_proof_failures=true"
|
|
exec("rm nimcache/coverage/*.c")
|
|
rmDir("coverage"); mkDir("coverage")
|
|
echo " ======== Running LCOV ======== "
|
|
exec("lcov --capture --directory nimcache/coverage --output-file coverage/coverage.info")
|
|
exec("lcov --extract coverage/coverage.info --output-file coverage/coverage.f.info " & nimSrcs)
|
|
echo " ======== Generating HTML coverage report ======== "
|
|
exec("genhtml coverage/coverage.f.info --output-directory coverage/report ")
|
|
echo " ======== Coverage report Done ======== "
|
|
|
|
task showCoverage, "open coverage html":
|
|
echo " ======== Opening HTML coverage report in browser... ======== "
|
|
if findExe("open") != "":
|
|
exec("open coverage/report/index.html")
|