From b63e064b4af46e29609854f66068ce6a4523d0c9 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Mon, 14 Jun 2021 17:21:44 -0600 Subject: [PATCH] Remove asynccheck (#590) * Merge master (#555) * Revisit Floodsub (#543) Fixes #525 add coverage to unsubscribeAll and testing * add mounted protos to identify message (#546) * add stable/unstable auto bumps * fix auto-bump CI * merge nbc auto bump with CI in order to bump only on CI success * put conditional locks on nbc bump (#549) * Fix minor exception issues (#550) Makes code compatible with https://github.com/status-im/nim-chronos/pull/166 without requiring it. * fix nimbus ref for auto-bump stable's PR * Split dialer (#542) * extracting dialing logic to dialer * exposing upgrade methods on transport * cleanup * fixing tests to use new interfaces * add comments * add base exception class and fix hierarchy * fix imports * `doAssert` is `ValueError` not `AssertionError`? * revert back to `AssertionError` Co-authored-by: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Co-authored-by: Jacek Sieka * Merge master (#555) * Revisit Floodsub (#543) Fixes #525 add coverage to unsubscribeAll and testing * add mounted protos to identify message (#546) * add stable/unstable auto bumps * fix auto-bump CI * merge nbc auto bump with CI in order to bump only on CI success * put conditional locks on nbc bump (#549) * Fix minor exception issues (#550) Makes code compatible with https://github.com/status-im/nim-chronos/pull/166 without requiring it. * fix nimbus ref for auto-bump stable's PR * Split dialer (#542) * extracting dialing logic to dialer * exposing upgrade methods on transport * cleanup * fixing tests to use new interfaces * add comments * add base exception class and fix hierarchy * fix imports * `doAssert` is `ValueError` not `AssertionError`? * revert back to `AssertionError` Co-authored-by: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Co-authored-by: Jacek Sieka * cleanup Co-authored-by: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Co-authored-by: Jacek Sieka --- docs/tutorial/directchat/second.nim | 4 ++-- docs/tutorial/second.nim | 4 ++-- examples/directchat.nim | 4 ++-- examples/go-daemon/bootstrap.nim | 2 +- examples/go-daemon/chat.nim | 4 ++-- tests/testidentify.nim | 2 +- tests/testmultistream.nim | 6 +++--- tests/testnoise.nim | 6 +++--- tests/testping.nim | 2 +- tests/testtransport.nim | 18 +++++++++--------- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/tutorial/directchat/second.nim b/docs/tutorial/directchat/second.nim index c910b1040..2c7b1a3a2 100644 --- a/docs/tutorial/directchat/second.nim +++ b/docs/tutorial/directchat/second.nim @@ -117,8 +117,8 @@ proc writeAndPrint(p: ChatProto) {.async.} = echo getCurrentExceptionMsg() proc readWriteLoop(p: ChatProto) {.async.} = - asyncCheck p.writeAndPrint() # execute the async function but does not block - asyncCheck p.readAndPrint() + asyncSpawn p.writeAndPrint() # execute the async function but does not block + asyncSpawn p.readAndPrint() proc processInput(rfd: AsyncFD) {.async.} = let transp = fromPipe(rfd) diff --git a/docs/tutorial/second.nim b/docs/tutorial/second.nim index c910b1040..2c7b1a3a2 100644 --- a/docs/tutorial/second.nim +++ b/docs/tutorial/second.nim @@ -117,8 +117,8 @@ proc writeAndPrint(p: ChatProto) {.async.} = echo getCurrentExceptionMsg() proc readWriteLoop(p: ChatProto) {.async.} = - asyncCheck p.writeAndPrint() # execute the async function but does not block - asyncCheck p.readAndPrint() + asyncSpawn p.writeAndPrint() # execute the async function but does not block + asyncSpawn p.readAndPrint() proc processInput(rfd: AsyncFD) {.async.} = let transp = fromPipe(rfd) diff --git a/examples/directchat.nim b/examples/directchat.nim index dc48aa5c4..9ffb82818 100644 --- a/examples/directchat.nim +++ b/examples/directchat.nim @@ -120,8 +120,8 @@ proc writeAndPrint(p: ChatProto) {.async.} = echo getCurrentExceptionMsg() proc readWriteLoop(p: ChatProto) {.async.} = - asyncCheck p.writeAndPrint() # execute the async function but does not block - asyncCheck p.readAndPrint() + asyncSpawn p.writeAndPrint() # execute the async function but does not block + asyncSpawn p.readAndPrint() proc newChatProto(switch: Switch, transp: StreamTransport): ChatProto = var chatproto = ChatProto(switch: switch, transp: transp, codecs: @[ChatCodec]) diff --git a/examples/go-daemon/bootstrap.nim b/examples/go-daemon/bootstrap.nim index 8218265fa..69523edd2 100644 --- a/examples/go-daemon/bootstrap.nim +++ b/examples/go-daemon/bootstrap.nim @@ -35,7 +35,7 @@ proc main() {.async.} = if item.protoCode() == mcip4 or item.protoCode() == mcip6: echo $item & "/ipfs/" & id.peer.pretty() - asyncCheck monitor(api) + asyncSpawn monitor(api) proc pubsubLogger(api: DaemonAPI, ticket: PubsubTicket, diff --git a/examples/go-daemon/chat.nim b/examples/go-daemon/chat.nim index 36a2f8658..c18111dd2 100644 --- a/examples/go-daemon/chat.nim +++ b/examples/go-daemon/chat.nim @@ -19,7 +19,7 @@ proc threadMain(wfd: AsyncFD) {.thread.} = ## This procedure performs reading from `stdin` and sends data over ## pipe to main thread. var transp = fromPipe(wfd) - + while true: var line = stdin.readLine() let res = waitFor transp.write(line & "\r\n") @@ -55,7 +55,7 @@ proc serveThread(udata: CustomData) {.async.} = var stream = await udata.api.openStream(peerId, ServerProtocols) udata.remotes.add(stream.transp) echo "= Connected to peer chat ", parts[1] - asyncCheck remoteReader(stream.transp) + asyncSpawn remoteReader(stream.transp) elif line.startsWith("/search"): var parts = line.split(" ") if len(parts) == 2: diff --git a/tests/testidentify.nim b/tests/testidentify.nim index 468d489e0..b23caed41 100644 --- a/tests/testidentify.nim +++ b/tests/testidentify.nim @@ -101,7 +101,7 @@ suite "Identify": asyncTest "handle failed identify": msListen.addHandler(IdentifyCodec, identifyProto1) - asyncCheck transport1.start(ma) + asyncSpawn transport1.start(ma) proc acceptHandler() {.async.} = var conn: Connection diff --git a/tests/testmultistream.nim b/tests/testmultistream.nim index 4508fa743..47c0dd90a 100644 --- a/tests/testmultistream.nim +++ b/tests/testmultistream.nim @@ -249,7 +249,7 @@ suite "Multistream select": msListen.addHandler("/test/proto/1.0.0", protocol) let transport1 = TcpTransport.init(upgrade = Upgrade()) - asyncCheck transport1.start(ma) + asyncSpawn transport1.start(ma) proc acceptHandler(): Future[void] {.async, gcsafe.} = let conn = await transport1.accept() @@ -341,7 +341,7 @@ suite "Multistream select": msListen.addHandler("/test/proto/1.0.0", protocol) let transport1: TcpTransport = TcpTransport.init(upgrade = Upgrade()) - asyncCheck transport1.start(ma) + asyncSpawn transport1.start(ma) proc acceptHandler(): Future[void] {.async, gcsafe.} = let conn = await transport1.accept() @@ -379,7 +379,7 @@ suite "Multistream select": msListen.addHandler("/test/proto2/1.0.0", protocol) let transport1: TcpTransport = TcpTransport.init(upgrade = Upgrade()) - asyncCheck transport1.start(ma) + asyncSpawn transport1.start(ma) proc acceptHandler(): Future[void] {.async, gcsafe.} = let conn = await transport1.accept() diff --git a/tests/testnoise.nim b/tests/testnoise.nim index e50ef6fde..c83a9664c 100644 --- a/tests/testnoise.nim +++ b/tests/testnoise.nim @@ -91,7 +91,7 @@ suite "Noise": serverNoise = Noise.new(rng, serverInfo.privateKey, outgoing = false) let transport1: TcpTransport = TcpTransport.init(upgrade = Upgrade()) - asyncCheck transport1.start(server) + asyncSpawn transport1.start(server) proc acceptHandler() {.async.} = let conn = await transport1.accept() @@ -130,7 +130,7 @@ suite "Noise": let transport1: TcpTransport = TcpTransport.init(upgrade = Upgrade()) - asyncCheck transport1.start(server) + asyncSpawn transport1.start(server) proc acceptHandler() {.async, gcsafe.} = var conn: Connection @@ -165,7 +165,7 @@ suite "Noise": readTask = newFuture[void]() let transport1: TcpTransport = TcpTransport.init(upgrade = Upgrade()) - asyncCheck transport1.start(server) + asyncSpawn transport1.start(server) proc acceptHandler() {.async, gcsafe.} = let conn = await transport1.accept() diff --git a/tests/testping.nim b/tests/testping.nim index d94f00f38..4ebd1885a 100644 --- a/tests/testping.nim +++ b/tests/testping.nim @@ -78,7 +78,7 @@ suite "Ping": let transport: TcpTransport = TcpTransport.init(upgrade = Upgrade()) let transportdialer: TcpTransport = TcpTransport.init(upgrade = Upgrade()) - asyncCheck transport.start(baseMa) + asyncSpawn transport.start(baseMa) proc acceptHandler() {.async, gcsafe.} = let handler = Ping.new().handler diff --git a/tests/testtransport.nim b/tests/testtransport.nim index 360e6598d..9b903f977 100644 --- a/tests/testtransport.nim +++ b/tests/testtransport.nim @@ -19,7 +19,7 @@ suite "TCP transport": asyncTest "test listener: handle write": let ma: MultiAddress = Multiaddress.init("/ip4/0.0.0.0/tcp/0").tryGet() let transport: TcpTransport = TcpTransport.init(upgrade = Upgrade()) - asyncCheck transport.start(ma) + asyncSpawn transport.start(ma) proc acceptHandler() {.async, gcsafe.} = let conn = await transport.accept() @@ -32,7 +32,7 @@ suite "TCP transport": let msg = await streamTransport.read(6) - await handlerWait.wait(5000.millis) # when no issues will not wait that long! + await handlerWait.wait(1.seconds) # when no issues will not wait that long! await streamTransport.closeWait() await transport.stop() check string.fromBytes(msg) == "Hello!" @@ -41,7 +41,7 @@ suite "TCP transport": let ma: MultiAddress = Multiaddress.init("/ip4/0.0.0.0/tcp/0").tryGet() let transport: TcpTransport = TcpTransport.init(upgrade = Upgrade()) - asyncCheck transport.start(ma) + asyncSpawn transport.start(ma) proc acceptHandler() {.async, gcsafe.} = var msg = newSeq[byte](6) @@ -54,7 +54,7 @@ suite "TCP transport": let streamTransport: StreamTransport = await connect(transport.ma) let sent = await streamTransport.write("Hello!") - await handlerWait.wait(5000.millis) # when no issues will not wait that long! + await handlerWait.wait(1.seconds) # when no issues will not wait that long! await streamTransport.closeWait() await transport.stop() @@ -84,7 +84,7 @@ suite "TCP transport": await conn.readExactly(addr msg[0], 6) check string.fromBytes(msg) == "Hello!" - await handlerWait.wait(5000.millis) # when no issues will not wait that long! + await handlerWait.wait(1.seconds) # when no issues will not wait that long! await conn.close() await transport.stop() @@ -116,7 +116,7 @@ suite "TCP transport": let conn = await transport.dial(ma) await conn.write("Hello!") - await handlerWait.wait(5000.millis) # when no issues will not wait that long! + await handlerWait.wait(1.seconds) # when no issues will not wait that long! await conn.close() await transport.stop() @@ -143,7 +143,7 @@ suite "TCP transport": var msg = newSeq[byte](6) await conn.readExactly(addr msg[0], 6) - await handlerWait.wait(5000.millis) # when no issues will not wait that long! + await handlerWait.wait(1.seconds) # when no issues will not wait that long! await conn.close() await transport2.stop() @@ -154,7 +154,7 @@ suite "TCP transport": asyncTest "e2e: handle read": let ma: MultiAddress = Multiaddress.init("/ip4/0.0.0.0/tcp/0").tryGet() let transport1: TcpTransport = TcpTransport.init(upgrade = Upgrade()) - asyncCheck transport1.start(ma) + asyncSpawn transport1.start(ma) proc acceptHandler() {.async, gcsafe.} = let conn = await transport1.accept() @@ -169,7 +169,7 @@ suite "TCP transport": let conn = await transport2.dial(transport1.ma) await conn.write("Hello!") - await handlerWait.wait(5000.millis) # when no issues will not wait that long! + await handlerWait.wait(1.seconds) # when no issues will not wait that long! await conn.close() await transport2.stop()