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 <jacek@status.im> * 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 <jacek@status.im> * cleanup Co-authored-by: Giovanni Petrantoni <7008900+sinkingsugar@users.noreply.github.com> Co-authored-by: Jacek Sieka <jacek@status.im>
This commit is contained in:
parent
bed00ec43c
commit
b63e064b4a
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue