tests are building

This commit is contained in:
thatben 2025-06-02 15:30:12 +02:00
parent c374dfc844
commit 6514e32919
No known key found for this signature in database
GPG Key ID: 62C543548433D43E
13 changed files with 80 additions and 76 deletions

View File

@ -130,31 +130,6 @@ test: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim test $(NIM_PARAMS) build.nims
# Builds and runs the smart contract tests
testContracts: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim testContracts $(NIM_PARAMS) --define:ws_resubscribe=240 build.nims
# Builds and runs the integration tests
testIntegration: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim testIntegration $(NIM_PARAMS) --define:ws_resubscribe=240 build.nims
# Builds and runs all tests (except for Taiko L2 tests)
testAll: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim testAll $(NIM_PARAMS) build.nims
# Builds and runs Taiko L2 tests
testTaiko: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim testTaiko $(NIM_PARAMS) build.nims
# Builds and runs tool tests
testTools: | cirdl
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim testTools $(NIM_PARAMS) build.nims
# nim-libbacktrace
LIBBACKTRACE_MAKE_FLAGS := -C vendor/nim-libbacktrace --no-print-directory BUILD_CXX_LIB=0
libbacktrace:

View File

@ -34,9 +34,9 @@ task codexcrawler, "build codexcrawler binary":
params = "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE"
task testCodexcrawler, "Build & run Codex Crawler tests":
test "testCodexCrawler", params = "-d:codex_enable_proof_failures=true"
test "testCodexCrawler"
task build, "build codex binary":
task build, "build codex crawler binary":
codexCrawlerTask()
task test, "Run tests":

View File

@ -34,9 +34,12 @@ suite "ChainMetrics":
teardown:
state.checkAllUnsubscribed()
proc onStep() {.async.} =
(await state.steppers[0]()).tryGet()
proc onStep() {.async: (raises: []).} =
try:
(await state.steppers[0]()).tryGet()
except CatchableError:
raiseAssert("CatchableError in onStep")
test "start should start stepper for config.requestCheckDelay minutes":
check:
state.delays.len == 1

View File

@ -35,9 +35,12 @@ suite "DhtCrawler":
teardown:
state.checkAllUnsubscribed()
proc onStep() {.async.} =
(await state.steppers[0]()).tryGet()
proc onStep() {.async: (raises: []).} =
try:
(await state.steppers[0]()).tryGet()
except CatchableError:
raiseAssert("CatchableError in onStep")
proc responsive(nid: Nid): GetNeighborsResponse =
GetNeighborsResponse(isResponsive: true, nodeIds: @[nid])
@ -68,7 +71,7 @@ suite "DhtCrawler":
test "nodes returned by getNeighbors are raised as nodesFound":
var nodesFound = newSeq[Nid]()
proc onNodesFound(nids: seq[Nid]): Future[?!void] {.async.} =
proc onNodesFound(nids: seq[Nid]): Future[?!void] {.async: (raises: [CancelledError]).} =
nodesFound = nids
return success()
@ -86,7 +89,7 @@ suite "DhtCrawler":
test "responsive result from getNeighbors raises the node as successful dhtNodeCheck":
var checkEvent = DhtNodeCheckEventData()
proc onCheck(event: DhtNodeCheckEventData): Future[?!void] {.async.} =
proc onCheck(event: DhtNodeCheckEventData): Future[?!void] {.async: (raises: [CancelledError]).} =
checkEvent = event
return success()
@ -105,7 +108,7 @@ suite "DhtCrawler":
test "unresponsive result from getNeighbors raises the node as unsuccessful dhtNodeCheck":
var checkEvent = DhtNodeCheckEventData()
proc onCheck(event: DhtNodeCheckEventData): Future[?!void] {.async.} =
proc onCheck(event: DhtNodeCheckEventData): Future[?!void] {.async: (raises: [CancelledError]).} =
checkEvent = event
return success()

View File

@ -35,13 +35,18 @@ suite "DhtMetrics":
(await dhtmetrics.stop()).tryGet()
state.checkAllUnsubscribed()
proc fireDhtNodeCheckEvent(isOk: bool) {.async.} =
proc fireDhtNodeCheckEvent(isOk: bool) {.async: (raises: []).} =
let event = DhtNodeCheckEventData(id: nid, isOk: isOk)
try:
(await state.events.dhtNodeCheck.fire(event)).tryGet()
except CatchableError:
raiseAssert("CatchableError in fireDhtNodeCheckEvent")
(await state.events.dhtNodeCheck.fire(event)).tryGet()
proc fireNodesDeletedEvent(nids: seq[Nid]) {.async.} =
(await state.events.nodesDeleted.fire(nids)).tryGet()
proc fireNodesDeletedEvent(nids: seq[Nid]) {.async: (raises: []).} =
try:
(await state.events.nodesDeleted.fire(nids)).tryGet()
except CatchableError:
raiseAssert("CatchableError in fireNodesDeletedEvent")
test "dhtmetrics start should load both lists":
check:

View File

@ -38,11 +38,17 @@ suite "Nodestore":
state.checkAllUnsubscribed()
removeDir(dsPath)
proc fireNodeFoundEvent(nids: seq[Nid]) {.async.} =
(await state.events.nodesFound.fire(nids)).tryGet()
proc fireNodeFoundEvent(nids: seq[Nid]) {.async: (raises: []).} =
try:
(await state.events.nodesFound.fire(nids)).tryGet()
except CatchableError:
raiseAssert("CatchableError in fireNodeFoundEvent")
proc fireCheckEvent(nid: Nid, isOk: bool) {.async.} =
(await state.events.dhtNodeCheck.fire(DhtNodeCheckEventData(id: nid, isOk: isOk))).tryGet()
proc fireCheckEvent(nid: Nid, isOk: bool) {.async: (raises: []).} =
try:
(await state.events.dhtNodeCheck.fire(DhtNodeCheckEventData(id: nid, isOk: isOk))).tryGet()
except CatchableError:
raiseAssert("CatchableError in fireCheckEvent")
test "nodeEntry encoding":
let entry =
@ -73,7 +79,7 @@ suite "Nodestore":
test "nodesFound event should fire newNodesDiscovered":
var newNodes = newSeq[Nid]()
proc onNewNodes(nids: seq[Nid]): Future[?!void] {.async.} =
proc onNewNodes(nids: seq[Nid]): Future[?!void] {.async: (raises: [CancelledError]).} =
newNodes = nids
return success()
@ -97,7 +103,7 @@ suite "Nodestore":
var
newNodes = newSeq[Nid]()
count = 0
proc onNewNodes(nids: seq[Nid]): Future[?!void] {.async.} =
proc onNewNodes(nids: seq[Nid]): Future[?!void] {.async: (raises: [CancelledError]).} =
newNodes = nids
inc count
return success()
@ -175,7 +181,7 @@ suite "Nodestore":
test "deleteEntries fires nodesDeleted event":
var deletedNodes = newSeq[Nid]()
proc onDeleted(nids: seq[Nid]): Future[?!void] {.async.} =
proc onDeleted(nids: seq[Nid]): Future[?!void] {.async: (raises: [CancelledError]).} =
deletedNodes = nids
return success()
@ -245,7 +251,7 @@ suite "Nodestore":
test "dhtNodeCheck event for non-existing node should fire nodesDeleted":
var deletedNodes = newSeq[Nid]()
proc onDeleted(nids: seq[Nid]): Future[?!void] {.async.} =
proc onDeleted(nids: seq[Nid]): Future[?!void] {.async: (raises: [CancelledError]).} =
deletedNodes = nids
return success()

View File

@ -37,7 +37,7 @@ suite "TimeTracker":
# Subscribe to nodesToRevisit event
nodesToRevisitReceived = newSeq[Nid]()
proc onToRevisit(nids: seq[Nid]): Future[?!void] {.async.} =
proc onToRevisit(nids: seq[Nid]): Future[?!void] {.async: (raises: [CancelledError]).} =
nodesToRevisitReceived = nids
return success()
@ -53,11 +53,17 @@ suite "TimeTracker":
await state.events.nodesToRevisit.unsubscribe(sub)
state.checkAllUnsubscribed()
proc onStepCheck() {.async.} =
(await state.steppers[0]()).tryGet()
proc onStepCheck() {.async: (raises: []).} =
try:
(await state.steppers[0]()).tryGet()
except CatchableError:
raiseAssert("CatchableError in onStepCheck")
proc onStepRt() {.async.} =
(await state.steppers[1]()).tryGet()
proc onStepRt() {.async: (raises: []).} =
try:
(await state.steppers[1]()).tryGet()
except CatchableError:
raiseAssert("CatchableError in onStepRt")
proc createNodeInStore(lastVisit: uint64, firstInactive = 0.uint64): Nid =
let entry =
@ -120,7 +126,7 @@ suite "TimeTracker":
test "onStep raises routingTable nodes as nodesFound":
var nodesFound = newSeq[Nid]()
proc onNodesFound(nids: seq[Nid]): Future[?!void] {.async.} =
proc onNodesFound(nids: seq[Nid]): Future[?!void] {.async: (raises: [CancelledError]).} =
nodesFound = nids
return success()

View File

@ -29,11 +29,17 @@ suite "TodoList":
(await todo.stop()).tryGet()
state.checkAllUnsubscribed()
proc fireNewNodesDiscoveredEvent(nids: seq[Nid]) {.async.} =
(await state.events.newNodesDiscovered.fire(nids)).tryGet()
proc fireNewNodesDiscoveredEvent(nids: seq[Nid]) {.async: (raises: []).} =
try:
(await state.events.newNodesDiscovered.fire(nids)).tryGet()
except CatchableError:
raiseAssert("CatchableError in fireNewNodesDiscoveredEvent")
proc fireNodesToRevisitEvent(nids: seq[Nid]) {.async.} =
(await state.events.nodesToRevisit.fire(nids)).tryGet()
proc fireNodesToRevisitEvent(nids: seq[Nid]) {.async: (raises: []).} =
try:
(await state.events.nodesToRevisit.fire(nids)).tryGet()
except CatchableError:
raiseAssert("CatchableError in fireNodesToRevisitEvent")
test "discovered nodes are added to todo list":
await fireNewNodesDiscoveredEvent(@[nid])

View File

@ -12,17 +12,17 @@ type MockList* = ref object of List
removeSuccess*: bool
length*: int
method load*(this: MockList): Future[?!void] {.async.} =
method load*(this: MockList): Future[?!void] {.async: (raises: [CancelledError]).} =
this.loadCalled = true
return success()
method add*(this: MockList, nid: Nid): Future[?!void] {.async.} =
method add*(this: MockList, nid: Nid): Future[?!void] {.async: (raises: [CancelledError]).} =
this.added.add(nid)
if this.addSuccess:
return success()
return failure("test failure")
method remove*(this: MockList, nid: Nid): Future[?!void] {.async.} =
method remove*(this: MockList, nid: Nid): Future[?!void] {.async: (raises: [CancelledError]).} =
this.removed.add(nid)
if this.removeSuccess:
return success()

View File

@ -15,7 +15,7 @@ proc checkAllUnsubscribed*(s: MockState) =
s.events.dhtNodeCheck.listeners == 0
s.events.nodesToRevisit.listeners == 0
method whileRunning*(s: MockState, step: OnStep, delay: Duration) {.async.} =
method whileRunning*(s: MockState, step: OnStep, delay: Duration) {.async: (raises: [CancelledError]).} =
s.steppers.add(step)
s.delays.add(delay)

View File

@ -20,7 +20,7 @@ suite "AsyncDataEvent":
test "Successful event":
var data = ""
proc eventHandler(e: ExampleData): Future[?!void] {.async.} =
proc eventHandler(e: ExampleData): Future[?!void] {.async: (raises: [CancelledError]).} =
data = e.s
success()
@ -34,7 +34,7 @@ suite "AsyncDataEvent":
test "Multiple events":
var counter = 0
proc eventHandler(e: ExampleData): Future[?!void] {.async.} =
proc eventHandler(e: ExampleData): Future[?!void] {.async: (raises: [CancelledError]).} =
inc counter
success()
@ -54,15 +54,15 @@ suite "AsyncDataEvent":
data1 = ""
data2 = ""
data3 = ""
proc eventHandler1(e: ExampleData): Future[?!void] {.async.} =
proc eventHandler1(e: ExampleData): Future[?!void] {.async: (raises: [CancelledError]).} =
data1 = e.s
success()
proc eventHandler2(e: ExampleData): Future[?!void] {.async.} =
proc eventHandler2(e: ExampleData): Future[?!void] {.async: (raises: [CancelledError]).} =
data2 = e.s
success()
proc eventHandler3(e: ExampleData): Future[?!void] {.async.} =
proc eventHandler3(e: ExampleData): Future[?!void] {.async: (raises: [CancelledError]).} =
data3 = e.s
success()
@ -82,7 +82,7 @@ suite "AsyncDataEvent":
await event.unsubscribe(sub3)
test "Failed event preserves error message":
proc eventHandler(e: ExampleData): Future[?!void] {.async.} =
proc eventHandler(e: ExampleData): Future[?!void] {.async: (raises: [CancelledError]).} =
failure(msg)
let s = event.subscribe(eventHandler)
@ -100,15 +100,15 @@ suite "AsyncDataEvent":
data2 = ""
data3 = ""
proc handler1(e: ExampleData): Future[?!void] {.async.} =
proc handler1(e: ExampleData): Future[?!void] {.async: (raises: [CancelledError]).} =
data1 = e.s
success()
proc handler2(e: ExampleData): Future[?!void] {.async.} =
proc handler2(e: ExampleData): Future[?!void] {.async: (raises: [CancelledError]).} =
data2 = e.s
success()
proc handler3(e: ExampleData): Future[?!void] {.async.} =
proc handler3(e: ExampleData): Future[?!void] {.async: (raises: [CancelledError]).} =
data3 = e.s
success()
@ -134,18 +134,18 @@ suite "AsyncDataEvent":
isOK(await event.fire(ExampleData(s: msg)))
test "Can unsubscribe in handler":
proc doNothing() {.async, closure.} =
proc doNothing() {.async: (raises: [CancelledError]), closure.} =
await sleepAsync(1.millis)
var callback = doNothing
proc eventHandler(e: ExampleData): Future[?!void] {.async.} =
proc eventHandler(e: ExampleData): Future[?!void] {.async: (raises: [CancelledError]).} =
await callback()
success()
let s = event.subscribe(eventHandler)
proc doUnsubscribe() {.async.} =
proc doUnsubscribe() {.async: (raises: [CancelledError]).} =
await event.unsubscribe(s)
callback = doUnsubscribe

View File

@ -11,4 +11,4 @@ requires "asynctest >= 0.5.2 & < 0.6.0"
requires "unittest2 <= 0.3.0"
task test, "Run tests":
exec "nim c -r test.nim"
exec "nim c -r testCodexCrawler.nim"