diff --git a/codex/blockexchange/engine/discovery.nim b/codex/blockexchange/engine/discovery.nim index 09085fcb0..857a60cd3 100644 --- a/codex/blockexchange/engine/discovery.nim +++ b/codex/blockexchange/engine/discovery.nim @@ -105,8 +105,7 @@ proc advertiseQueueLoop(b: DiscoveryEngine) {.async.} = trace "Begin iterating blocks..." for c in cids: if cid =? await c: - b.advertiseBlock(cid) - await sleepAsync(100.millis) + await b.advertiseBlock(cid) trace "Iterating blocks finished." await sleepAsync(b.advertiseLoopSleep) diff --git a/codex/blocktype.nim b/codex/blocktype.nim index dd3b70e04..c44e4fd88 100644 --- a/codex/blocktype.nim +++ b/codex/blocktype.nim @@ -31,7 +31,7 @@ import ./codextypes export errors, logutils, units, codextypes type - Block* = object of RootObj + Block* = ref object of RootObj cid*: Cid data*: seq[byte] diff --git a/codex/manifest/manifest.nim b/codex/manifest/manifest.nim index 5966feb30..93aa5ba5b 100644 --- a/codex/manifest/manifest.nim +++ b/codex/manifest/manifest.nim @@ -29,7 +29,7 @@ import ../logutils # TODO: Manifest should be reworked to more concrete types, # perhaps using inheritance type - Manifest* = object of RootObj + Manifest* = ref object of RootObj treeCid {.serialize.}: Cid # Root of the merkle tree datasetSize {.serialize.}: NBytes # Total size of all blocks blockSize {.serialize.}: NBytes # Size of each contained block (might not be needed if blocks are len-prefixed) diff --git a/config.nims b/config.nims index 45830fada..b64aacbdc 100644 --- a/config.nims +++ b/config.nims @@ -121,6 +121,9 @@ switch("define", "ctt_asm=false") # Allow the use of old-style case objects for nim config compatibility switch("define", "nimOldCaseObjects") +# Enable compat mode for Chronos V4 +switch("define", "chronosHandleException") + # begin Nimble config (version 1) when system.fileExists("nimble.paths"): include "nimble.paths" diff --git a/tests/codex/sales/testsales.nim b/tests/codex/sales/testsales.nim index 543a7133e..0fdf3bf9e 100644 --- a/tests/codex/sales/testsales.nim +++ b/tests/codex/sales/testsales.nim @@ -323,8 +323,7 @@ asyncchecksuite "Sales": slot: UInt256, onBatch: BatchProc): Future[?!void] {.async.} = let blk = bt.Block.new( @[1.byte] ).get - onBatch( blk.repeat(request.ask.slotSize.truncate(int)) ) - return success() + await onBatch( blk.repeat(request.ask.slotSize.truncate(int)) ) createAvailability() await market.requestStorage(request) @@ -337,8 +336,8 @@ asyncchecksuite "Sales": onBatch: BatchProc): Future[?!void] {.async.} = slotIndex = slot let blk = bt.Block.new( @[1.byte] ).get - onBatch(@[ blk ]) - return success() + await onBatch(@[ blk ]) + let sold = newFuture[void]() sales.onSale = proc(request: StorageRequest, slotIndex: UInt256) = sold.complete() diff --git a/tests/codex/sales/testslotqueue.nim b/tests/codex/sales/testslotqueue.nim index 71ac85976..193751c8a 100644 --- a/tests/codex/sales/testslotqueue.nim +++ b/tests/codex/sales/testslotqueue.nim @@ -524,7 +524,7 @@ suite "Slot queue": request.ask, request.expiry, seen = true) - queue.push(item) + check queue.push(item).isOk check eventually queue.paused check onProcessSlotCalledWith.len == 0 @@ -534,7 +534,7 @@ suite "Slot queue": let request = StorageRequest.example var items = SlotQueueItem.init(request) - queue.push(items) + check queue.push(items).isOk # check all items processed check eventually queue.len == 0 @@ -546,7 +546,7 @@ suite "Slot queue": request.expiry, seen = true) check queue.paused - queue.push(item0) + check queue.push(item0).isOk check queue.paused test "paused queue waits for unpause before continuing processing": @@ -558,7 +558,7 @@ suite "Slot queue": seen = false) check queue.paused # push causes unpause - queue.push(item) + check queue.push(item).isOk # check all items processed check eventually onProcessSlotCalledWith == @[ (item.requestId, item.slotIndex), @@ -576,8 +576,8 @@ suite "Slot queue": request.ask, request.expiry, seen = true) - queue.push(item0) - queue.push(item1) + check queue.push(item0).isOk + check queue.push(item1).isOk check queue[0].seen check queue[1].seen diff --git a/tests/contracts/testMarket.nim b/tests/contracts/testMarket.nim index 9a94acf7b..35b46279c 100644 --- a/tests/contracts/testMarket.nim +++ b/tests/contracts/testMarket.nim @@ -256,7 +256,7 @@ ethersuite "On-Chain Market": receivedIds.add(requestId) let subscription = await market.subscribeRequestCancelled(request.id, onRequestCancelled) - advanceToCancelledRequest(otherRequest) # shares expiry with otherRequest + await advanceToCancelledRequest(otherRequest) # shares expiry with otherRequest await market.withdrawFunds(otherRequest.id) check receivedIds.len == 0 await market.withdrawFunds(request.id) diff --git a/tests/ethertest.nim b/tests/ethertest.nim index 8859f714e..8a9c473eb 100644 --- a/tests/ethertest.nim +++ b/tests/ethertest.nim @@ -25,5 +25,5 @@ template ethersuite*(name, body) = body -export unittest +export asynctest export ethers except `%` diff --git a/tests/helpers/multisetup.nim b/tests/helpers/multisetup.nim index 7a0ea4c38..781b0062c 100644 --- a/tests/helpers/multisetup.nim +++ b/tests/helpers/multisetup.nim @@ -2,8 +2,9 @@ import pkg/chronos # Allow multiple setups and teardowns in a test suite template asyncmultisetup* = - var setups: seq[proc: Future[void] {.gcsafe.}] - var teardowns: seq[proc: Future[void] {.gcsafe.}] + var setups: seq[proc: Future[void].Raising([AsyncExceptionError]) {.gcsafe.}] + var teardowns: seq[ + proc: Future[void].Raising([AsyncExceptionError]) {.gcsafe.}] setup: for setup in setups: @@ -14,10 +15,12 @@ template asyncmultisetup* = await teardown() template setup(setupBody) {.inject, used.} = - setups.add(proc {.async.} = setupBody) + setups.add(proc {.async: ( + handleException: true, raises: [AsyncExceptionError]).} = setupBody) template teardown(teardownBody) {.inject, used.} = - teardowns.insert(proc {.async.} = teardownBody) + teardowns.insert(proc {.async: ( + handleException: true, raises: [AsyncExceptionError]).} = teardownBody) template multisetup* = var setups: seq[proc() {.gcsafe.}] @@ -32,7 +35,8 @@ template multisetup* = teardown() template setup(setupBody) {.inject, used.} = - setups.add(proc = setupBody) + let setupProc = proc = setupBody + setups.add(setupProc) template teardown(teardownBody) {.inject, used.} = teardowns.insert(proc = teardownBody) diff --git a/tests/integration/codexprocess.nim b/tests/integration/codexprocess.nim index 07760b43b..ce6334340 100644 --- a/tests/integration/codexprocess.nim +++ b/tests/integration/codexprocess.nim @@ -2,6 +2,7 @@ import pkg/questionable import pkg/questionable/results import pkg/confutils import pkg/chronicles +import pkg/chronos/asyncproc import pkg/ethers import pkg/libp2p import std/os diff --git a/tests/integration/hardhatprocess.nim b/tests/integration/hardhatprocess.nim index e4291748a..6cfab47de 100644 --- a/tests/integration/hardhatprocess.nim +++ b/tests/integration/hardhatprocess.nim @@ -3,6 +3,7 @@ import pkg/questionable/results import pkg/confutils import pkg/chronicles import pkg/chronos +import pkg/chronos/asyncproc import pkg/stew/io2 import std/os import std/sets diff --git a/tests/integration/nodeprocess.nim b/tests/integration/nodeprocess.nim index 7bd0792d1..97f4507f2 100644 --- a/tests/integration/nodeprocess.nim +++ b/tests/integration/nodeprocess.nim @@ -2,6 +2,7 @@ import pkg/questionable import pkg/questionable/results import pkg/confutils import pkg/chronicles +import pkg/chronos/asyncproc import pkg/libp2p import std/os import std/strutils diff --git a/vendor/nim-chronos b/vendor/nim-chronos index 0277b65be..035ae11ba 160000 --- a/vendor/nim-chronos +++ b/vendor/nim-chronos @@ -1 +1 @@ -Subproject commit 0277b65be2c7a365ac13df002fba6e172be55537 +Subproject commit 035ae11ba92369e7722e649db597e79134fd06b9 diff --git a/vendor/nim-codex-dht b/vendor/nim-codex-dht index a7f14bc9b..63822e835 160000 --- a/vendor/nim-codex-dht +++ b/vendor/nim-codex-dht @@ -1 +1 @@ -Subproject commit a7f14bc9b783f1b9e2d02cc85a338b1411058095 +Subproject commit 63822e83561ea1c6396d0f3eca583b038f5d44c6 diff --git a/vendor/nim-http-utils b/vendor/nim-http-utils index 3b491a40c..be57dbc90 160000 --- a/vendor/nim-http-utils +++ b/vendor/nim-http-utils @@ -1 +1 @@ -Subproject commit 3b491a40c60aad9e8d3407443f46f62511e63b18 +Subproject commit be57dbc902d36f37540897e98c69aa80f868cb45 diff --git a/vendor/nimbus-build-system b/vendor/nimbus-build-system index fe9bc3f37..b2e1fb022 160000 --- a/vendor/nimbus-build-system +++ b/vendor/nimbus-build-system @@ -1 +1 @@ -Subproject commit fe9bc3f3759ae1add6bf8c899db2e75327f03782 +Subproject commit b2e1fb022f1ee800b439648953e92cc993c1264c