add minimal changes to get compilation of tests with Chronos V4 + latest asynctest

This commit is contained in:
gmega 2024-01-10 18:25:57 -03:00
parent 6754112a25
commit 591895f225
No known key found for this signature in database
GPG Key ID: FFD8DAF00660270F
44 changed files with 158 additions and 95 deletions

View File

@ -8,3 +8,7 @@ proc asyncSpawn*(future: Future[void], ignore: type CatchableError) =
discard
asyncSpawn ignoringError()
proc asyncSpawn*[T](future: Future[T]): void =
proc task() {.async.} = discard await future
asyncSpawn task()

View File

@ -3,25 +3,28 @@ import ./helpers
## Unit testing suite that calls checkTrackers in teardown to check for memory leaks using chronos trackers.
template checksuite*(name, body) =
suite name:
multisetup()
teardown:
checkTrackers()
proc suiteProc =
multisetup()
teardown:
checkTrackers()
# Avoids GcUnsafe2 warnings with chronos
# Copied from asynctest/templates.nim
let suiteproc = proc =
body
suiteproc()
suiteProc()
template asyncchecksuite*(name, body) =
suite name:
asyncmultisetup()
teardown:
checkTrackers()
proc suiteProc =
asyncmultisetup()
body
teardown:
checkTrackers()
body
suiteProc()
export helpers

View File

@ -2,7 +2,7 @@ import std/sequtils
import std/sugar
import std/tables
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/libp2p/errors
@ -120,7 +120,10 @@ asyncchecksuite "Block Advertising and Discovery":
advertised = newFuture[Cid]()
blockDiscovery
.publishBlockProvideHandler = proc(d: MockDiscovery, cid: Cid) {.async.} =
.publishBlockProvideHandler = proc(
d: MockDiscovery,
cid: Cid
) {.async: (handleException: true).} =
check manifestBlock.cid == cid
advertised.complete(cid)
@ -162,7 +165,10 @@ asyncchecksuite "Block Advertising and Discovery":
))
blockDiscovery.findBlockProvidersHandler =
proc(d: MockDiscovery, cid: Cid): Future[seq[SignedPeerRecord]] =
proc(
d: MockDiscovery,
cid: Cid
): Future[seq[SignedPeerRecord]] {.async: (handleException: true).} =
check false
await engine.start() # fire up discovery loop

View File

@ -2,7 +2,7 @@ import std/sequtils
import std/sugar
import std/tables
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
@ -100,7 +100,10 @@ asyncchecksuite "Test Discovery Engine":
want = newFuture[void]()
blockDiscovery.findBlockProvidersHandler =
proc(d: MockDiscovery, cid: Cid): Future[seq[SignedPeerRecord]] {.async, gcsafe.} =
proc(
d: MockDiscovery,
cid: Cid
): Future[seq[SignedPeerRecord]] {.async: (handleException: true), gcsafe.} =
check cid == blocks[0].cid
if not want.finished:
want.complete()
@ -123,7 +126,10 @@ asyncchecksuite "Test Discovery Engine":
have = newFuture[void]()
blockDiscovery.publishBlockProvideHandler =
proc(d: MockDiscovery, cid: Cid) {.async, gcsafe.} =
proc(
d: MockDiscovery,
cid: Cid
) {.async: (handleException: true), gcsafe.} =
check cid == blocks[0].cid
if not have.finished:
have.complete()
@ -147,7 +153,10 @@ asyncchecksuite "Test Discovery Engine":
want = newAsyncEvent()
blockDiscovery.findBlockProvidersHandler =
proc(d: MockDiscovery, cid: Cid): Future[seq[SignedPeerRecord]] {.async, gcsafe.} =
proc(
d: MockDiscovery,
cid: Cid
): Future[seq[SignedPeerRecord]] {.async: (handleException: true), gcsafe.} =
check cid == blocks[0].cid
check peerStore.len < minPeers
@ -184,8 +193,10 @@ asyncchecksuite "Test Discovery Engine":
count = 0
blockDiscovery.findBlockProvidersHandler =
proc(d: MockDiscovery, cid: Cid):
Future[seq[SignedPeerRecord]] {.gcsafe, async.} =
proc(
d: MockDiscovery,
cid: Cid
): Future[seq[SignedPeerRecord]] {.gcsafe, async: (handleException: true).} =
check cid == blocks[0].cid
if count > 0:
check false
@ -218,7 +229,10 @@ asyncchecksuite "Test Discovery Engine":
count = 0
blockDiscovery.publishBlockProvideHandler =
proc(d: MockDiscovery, cid: Cid) {.async, gcsafe.} =
proc(
d: MockDiscovery,
cid: Cid
) {.async: (handleException: true), gcsafe.} =
check cid == blocks[0].cid
if count > 0:
check false

View File

@ -1,7 +1,7 @@
import std/sequtils
import std/algorithm
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/stew/byteutils

View File

@ -3,7 +3,7 @@ import std/random
import std/algorithm
import pkg/stew/byteutils
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/libp2p/errors
import pkg/libp2p/routing_record
@ -60,8 +60,8 @@ asyncchecksuite "NetworkStore engine basic":
cancel: bool = false,
wantType: WantType = WantType.WantHave,
full: bool = false,
sendDontHave: bool = false) {.gcsafe, async.} =
check addresses.mapIt($it.cidOrTreeCid).sorted == blocks.mapIt( $it.cid ).sorted
sendDontHave: bool = false) {.gcsafe, async: (handleException: true).} =
check addresses.mapIt($it.cidOrTreeCid).sorted == blocks.mapIt($it.cid).sorted
done.complete()
let
@ -94,7 +94,7 @@ asyncchecksuite "NetworkStore engine basic":
test "Should send account to new peers":
let pricing = Pricing.example
proc sendAccount(peer: PeerId, account: Account) {.gcsafe, async.} =
proc sendAccount(peer: PeerId, account: Account) {.gcsafe, async: (handleException: true).} =
check account.address == pricing.address
done.complete()
@ -189,7 +189,7 @@ asyncchecksuite "NetworkStore engine handlers":
blocks.mapIt( it.cid ),
wantType = WantType.WantBlock) # only `wantBlock` are stored in `peerWants`
proc handler() {.async.} =
proc handler() {.async: (handleException: true).} =
let ctx = await engine.taskQueue.pop()
check ctx.id == peerId
# only `wantBlock` scheduled
@ -204,7 +204,7 @@ asyncchecksuite "NetworkStore engine handlers":
done = newFuture[void]()
wantList = makeWantList(blocks.mapIt( it.cid ))
proc sendPresence(peerId: PeerId, presence: seq[BlockPresence]) {.gcsafe, async.} =
proc sendPresence(peerId: PeerId, presence: seq[BlockPresence]) {.gcsafe, async: (handleException: true).} =
check presence.mapIt( it.address ) == wantList.entries.mapIt( it.address )
done.complete()
@ -226,7 +226,7 @@ asyncchecksuite "NetworkStore engine handlers":
blocks.mapIt( it.cid ),
sendDontHave = true)
proc sendPresence(peerId: PeerId, presence: seq[BlockPresence]) {.gcsafe, async.} =
proc sendPresence(peerId: PeerId, presence: seq[BlockPresence]) {.gcsafe, async: (handleException: true).} =
check presence.mapIt( it.address ) == wantList.entries.mapIt( it.address )
for p in presence:
check:
@ -248,7 +248,7 @@ asyncchecksuite "NetworkStore engine handlers":
blocks.mapIt( it.cid ),
sendDontHave = true)
proc sendPresence(peerId: PeerId, presence: seq[BlockPresence]) {.gcsafe, async.} =
proc sendPresence(peerId: PeerId, presence: seq[BlockPresence]) {.gcsafe, async: (handleException: true).} =
for p in presence:
if p.address.cidOrTreeCid != blocks[0].cid and p.address.cidOrTreeCid != blocks[1].cid:
check p.`type` == BlockPresenceType.DontHave
@ -295,7 +295,7 @@ asyncchecksuite "NetworkStore engine handlers":
engine.network = BlockExcNetwork(
request: BlockExcRequest(
sendPayment: proc(receiver: PeerId, payment: SignedState) {.gcsafe, async.} =
sendPayment: proc(receiver: PeerId, payment: SignedState) {.gcsafe, async: (handleException: true).} =
let
amount =
blocks.mapIt(
@ -421,7 +421,7 @@ asyncchecksuite "Task Handler":
test "Should send want-blocks in priority order":
proc sendBlocksDelivery(
id: PeerId,
blocksDelivery: seq[BlockDelivery]) {.gcsafe, async.} =
blocksDelivery: seq[BlockDelivery]) {.gcsafe, async: (handleException: true).} =
check blocksDelivery.len == 2
check:
blocksDelivery[1].address == blocks[0].address
@ -458,7 +458,7 @@ asyncchecksuite "Task Handler":
let missing = @[Block.new("missing".toBytes).tryGet()]
let price = (!engine.pricing).price
proc sendPresence(id: PeerId, presence: seq[BlockPresence]) {.gcsafe, async.} =
proc sendPresence(id: PeerId, presence: seq[BlockPresence]) {.gcsafe, async: (handleException: true).} =
check presence.mapIt(!Presence.init(it)) == @[
Presence(address: present[0].address, have: true, price: price),
Presence(address: present[1].address, have: true, price: price),

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/stew/byteutils
import ../../examples

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/codex/blockexchange/protobuf/presence
@ -7,7 +7,7 @@ import ../../helpers
checksuite "block presence protobuf messages":
let
let
cid = Cid.example
address = BlockAddress(leaf: false, cid: cid)
price = UInt256.example

View File

@ -1,7 +1,7 @@
import std/sequtils
import std/tables
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/codex/rng
@ -47,7 +47,8 @@ asyncchecksuite "Network - Handlers":
discard await networkPeer.connect()
test "Want List handler":
proc wantListHandler(peer: PeerId, wantList: WantList) {.gcsafe, async.} =
proc wantListHandler(peer: PeerId, wantList: WantList) {.gcsafe,
async: (handleException: true).} =
# check that we got the correct amount of entries
check wantList.entries.len == 4
@ -74,7 +75,10 @@ asyncchecksuite "Network - Handlers":
await done.wait(500.millis)
test "Blocks Handler":
proc blocksDeliveryHandler(peer: PeerId, blocksDelivery: seq[BlockDelivery]) {.gcsafe, async.} =
proc blocksDeliveryHandler(
peer: PeerId,
blocksDelivery: seq[BlockDelivery]
) {.gcsafe, async: (handleException: true).} =
check blocks == blocksDelivery.mapIt(it.blk)
done.complete()
@ -88,7 +92,7 @@ asyncchecksuite "Network - Handlers":
test "Presence Handler":
proc presenceHandler(
peer: PeerId,
presence: seq[BlockPresence]) {.gcsafe, async.} =
presence: seq[BlockPresence]) {.gcsafe, async: (handleException: true).} =
for b in blocks:
check:
b.address in presence
@ -110,7 +114,10 @@ asyncchecksuite "Network - Handlers":
test "Handles account messages":
let account = Account(address: EthAddress.example)
proc handleAccount(peer: PeerId, received: Account) {.gcsafe, async.} =
proc handleAccount(
peer: PeerId,
received: Account
) {.gcsafe, async: (handleException: true).} =
check received == account
done.complete()
@ -124,7 +131,10 @@ asyncchecksuite "Network - Handlers":
test "Handles payment messages":
let payment = SignedState.example
proc handlePayment(peer: PeerId, received: SignedState) {.gcsafe, async.} =
proc handlePayment(
peer: PeerId,
received: SignedState
) {.gcsafe, async: (handleException: true).} =
check received == payment
done.complete()
@ -177,7 +187,10 @@ asyncchecksuite "Network - Senders":
switch2.stop())
test "Send want list":
proc wantListHandler(peer: PeerId, wantList: WantList) {.gcsafe, async.} =
proc wantListHandler(
peer: PeerId,
wantList: WantList
) {.gcsafe, async: (handleException: true).} =
# check that we got the correct amount of entries
check wantList.entries.len == 4
@ -201,7 +214,10 @@ asyncchecksuite "Network - Senders":
await done.wait(500.millis)
test "send blocks":
proc blocksDeliveryHandler(peer: PeerId, blocksDelivery: seq[BlockDelivery]) {.gcsafe, async.} =
proc blocksDeliveryHandler(
peer: PeerId,
blocksDelivery: seq[BlockDelivery]
) {.gcsafe, async: (handleException: true).} =
check blocks == blocksDelivery.mapIt(it.blk)
done.complete()
@ -215,7 +231,7 @@ asyncchecksuite "Network - Senders":
test "send presence":
proc presenceHandler(
peer: PeerId,
precense: seq[BlockPresence]) {.gcsafe, async.} =
precense: seq[BlockPresence]) {.gcsafe, async: (handleException: true).} =
for b in blocks:
check:
b.address in precense
@ -237,7 +253,10 @@ asyncchecksuite "Network - Senders":
test "send account":
let account = Account(address: EthAddress.example)
proc handleAccount(peer: PeerId, received: Account) {.gcsafe, async.} =
proc handleAccount(
peer: PeerId,
received: Account
) {.gcsafe, async: (handleException: true).} =
check received == account
done.complete()
@ -249,7 +268,10 @@ asyncchecksuite "Network - Senders":
test "send payment":
let payment = SignedState.example
proc handlePayment(peer: PeerId, received: SignedState) {.gcsafe, async.} =
proc handlePayment(
peer: PeerId,
received: SignedState
) {.gcsafe, async: (handleException: true).} =
check received == payment
done.complete()
@ -293,7 +315,10 @@ asyncchecksuite "Network - Test Limits":
test "Concurrent Sends":
let account = Account(address: EthAddress.example)
network2.handlers.onAccount =
proc(peer: PeerId, received: Account) {.gcsafe, async.} =
proc(
peer: PeerId,
received: Account
) {.gcsafe, async: (handleException: true).} =
check false
let fut = network1.send(

View File

@ -1,7 +1,7 @@
import std/sugar
import std/sequtils
import std/unittest
import pkg/unittest2
import pkg/libp2p
import pkg/codex/blockexchange/peers

View File

@ -2,7 +2,7 @@ import std/sequtils
import std/algorithm
import pkg/chronos
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/stew/byteutils
import pkg/codex/blocktype as bt

View File

@ -32,7 +32,7 @@ proc set*(clock: MockClock, time: SecondsSince1970) =
proc advance*(clock: MockClock, seconds: int64) =
clock.set(clock.time + seconds)
method now*(clock: MockClock): SecondsSince1970 =
method now*(clock: MockClock): SecondsSince1970 {.raises: [].} =
clock.time
method waitUntil*(clock: MockClock, time: SecondsSince1970) {.async.} =

View File

@ -16,13 +16,13 @@ import pkg/contractabi/address as ca
type
MockDiscovery* = ref object of Discovery
findBlockProvidersHandler*: proc(d: MockDiscovery, cid: Cid):
Future[seq[SignedPeerRecord]] {.gcsafe.}
Future[seq[SignedPeerRecord]] {.gcsafe, raises: [].}
publishBlockProvideHandler*: proc(d: MockDiscovery, cid: Cid):
Future[void] {.gcsafe.}
Future[void] {.gcsafe, raises: [].}
findHostProvidersHandler*: proc(d: MockDiscovery, host: ca.Address):
Future[seq[SignedPeerRecord]] {.gcsafe.}
Future[seq[SignedPeerRecord]] {.gcsafe, raises: [].}
publishHostProvideHandler*: proc(d: MockDiscovery, host: ca.Address):
Future[void] {.gcsafe.}
Future[void] {.gcsafe, raises: [].}
proc new*(T: type MockDiscovery): MockDiscovery =
MockDiscovery()
@ -32,7 +32,7 @@ proc findPeer*(
peerId: PeerId
): Future[?PeerRecord] {.async.} =
## mock find a peer - always return none
##
##
return none(PeerRecord)
method find*(

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/questionable/results
import pkg/codex/clock

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/questionable
import pkg/chronos
import pkg/codex/contracts/requests

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/questionable
import pkg/codex/contracts/requests

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/questionable
import pkg/codex/contracts/requests

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/codex/contracts/requests
import pkg/codex/sales
import pkg/codex/sales/salesagent

View File

@ -3,7 +3,7 @@ import std/random
import pkg/questionable
import pkg/questionable/results
import pkg/chronos
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/datastore
import pkg/codex/stores

View File

@ -1,7 +1,7 @@
import std/sequtils
import std/sugar
import std/times
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/datastore
import pkg/questionable
@ -14,6 +14,7 @@ import pkg/codex/sales/slotqueue
import pkg/codex/stores/repostore
import pkg/codex/blocktype as bt
import pkg/codex/node
import pkg/codex/utils/asyncspawn
import ../helpers
import ../helpers/mockmarket
import ../helpers/mockclock
@ -288,7 +289,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)) )
asyncSpawn onBatch( blk.repeat(request.ask.slotSize.truncate(int)) )
return success()
createAvailability()
@ -302,7 +303,7 @@ asyncchecksuite "Sales":
onBatch: BatchProc): Future[?!void] {.async.} =
slotIndex = slot
let blk = bt.Block.new( @[1.byte] ).get
onBatch(@[ blk ])
asyncSpawn onBatch(@[ blk ])
return success()
let sold = newFuture[void]()
sales.onSale = proc(request: StorageRequest, slotIndex: UInt256) =

View File

@ -1,5 +1,5 @@
import std/times
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/codex/sales
import pkg/codex/sales/salesagent

View File

@ -1,5 +1,6 @@
import std/sequtils
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronicles
import pkg/chronos
import pkg/datastore
import pkg/questionable

View File

@ -3,7 +3,7 @@ import std/strutils
import std/options
import pkg/chronos
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/libp2p/multicodec
import pkg/stew/byteutils
import pkg/questionable

View File

@ -1,7 +1,7 @@
import std/strutils
import pkg/chronos
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/stew/byteutils
import pkg/questionable/results
import pkg/codex/stores/cachestore

View File

@ -10,7 +10,7 @@
import std/random
import std/sequtils
import pkg/chronos
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/questionable
import pkg/questionable/results
import pkg/codex/blocktype as bt

View File

@ -8,7 +8,7 @@
## those terms.
import pkg/chronos
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/questionable/results
import pkg/codex/blocktype as bt
import pkg/codex/stores/repostore

View File

@ -6,7 +6,7 @@ import pkg/questionable
import pkg/questionable/results
import pkg/chronos
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/stew/byteutils
import pkg/stew/endians2
import pkg/datastore

View File

@ -1,5 +1,5 @@
import pkg/chronos
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/stew/results
import pkg/codex/utils/asyncheapqueue

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/chronos/transports/stream
import pkg/chronos/transports/common

View File

@ -1,5 +1,5 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/stew/byteutils
import pkg/codex/chunker
import pkg/codex/logutils

View File

@ -1,7 +1,7 @@
import std/sequtils
import std/sugar
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/datastore
import pkg/questionable/results
@ -35,7 +35,9 @@ suite "Erasure encode/decode":
erasure = Erasure.new(store, leoEncoderProvider, leoDecoderProvider)
manifest = await storeDataGetManifest(store, chunker)
proc encode(buffers, parity: int): Future[Manifest] {.async.} =
proc encode(
buffers, parity: int): Future[Manifest] {.async:
(handleException: true).} =
let
encoded = (await erasure.encode(
manifest,

View File

@ -2,7 +2,9 @@ import std/sequtils
import pkg/chronos
import pkg/questionable/results
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/stew/byteutils
import pkg/codex/chunker
import pkg/codex/blocktype as bt
import pkg/codex/manifest

View File

@ -1,5 +1,5 @@
import std/times
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/stint
import pkg/codex/purchasing

View File

@ -1,5 +1,5 @@
import pkg/chronos
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/questionable/results
import ./helpers

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import codex/validation

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/questionable
import pkg/chronos
import pkg/upraises
@ -22,7 +22,8 @@ method run(state: State1, machine: Machine): Future[?State] {.async.} =
inc runs[0]
return some State(State2.new())
method run(state: State2, machine: Machine): Future[?State] {.async.} =
method run(state: State2,
machine: Machine): Future[?State] {.async: (handleException: true).} =
inc runs[1]
try:
await sleepAsync(1.hours)

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/questionable
import pkg/questionable/results

View File

@ -8,7 +8,7 @@
## those terms.
import pkg/chronos
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import codex/utils/timer
import ../helpers

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import codex/utils/trackedfutures
import ../helpers

View File

@ -1,4 +1,4 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/ethers
import codex/contracts/deployment
import codex/conf

View File

@ -1,5 +1,5 @@
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/ethers
import ./checktest

View File

@ -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)

View File

@ -2,7 +2,7 @@ import std/times
import std/os
import std/json
import std/tempfiles
import pkg/asynctest
import pkg/asynctest/chronos/unittest
import pkg/chronos
import pkg/stint
import pkg/questionable

2
vendor/asynctest vendored

@ -1 +1 @@
Subproject commit fe1a34caf572b05f8bdba3b650f1871af9fce31e
Subproject commit 8e2f4e73b97123be0f0041c129942b32df23ecb1