diff --git a/tests/testmplex.nim b/tests/testmplex.nim index a876f33..f88e6f9 100644 --- a/tests/testmplex.nim +++ b/tests/testmplex.nim @@ -119,16 +119,12 @@ suite "Mplex": test "e2e - read/write receiver": proc testNewStream(): Future[bool] {.async.} = - let - ma: MultiAddress = Multiaddress.init("/ip4/0.0.0.0/tcp/0") - lock = newFuture[void]() - timeout = sleepAsync(5_000) + let ma: MultiAddress = Multiaddress.init("/ip4/0.0.0.0/tcp/0") proc connHandler(conn: Connection) {.async, gcsafe.} = proc handleMplexListen(stream: Connection) {.async, gcsafe.} = let msg = await stream.readLp() check cast[string](msg) == "Hello from stream!" - lock.complete() await stream.close() let mplexListen = newMplex(conn) @@ -176,9 +172,6 @@ suite "Mplex": let stream = await mplexDial.newStream("", true) let openState = cast[LPChannel](stream.stream).isOpen await stream.writeLp("Hello from stream!") - await lock or timeout - check lock.finished - timeout.cancel() await conn.close() check not openState # assert lazy result = true @@ -190,15 +183,14 @@ suite "Mplex": proc testNewStream(): Future[bool] {.async.} = let ma: MultiAddress = Multiaddress.init("/ip4/0.0.0.0/tcp/0") - lock = newFuture[void]() - timeout = sleepAsync(5_000) + listenJob = newFuture[void]() proc connHandler(conn: Connection) {.async, gcsafe.} = proc handleMplexListen(stream: Connection) {.async, gcsafe.} = let msg = await stream.readLp() - lock.complete() check cast[string](msg) == "Hello from stream!" await stream.close() + listenJob.complete() let mplexListen = newMplex(conn) mplexListen.streamHandler = handleMplexListen @@ -214,12 +206,10 @@ suite "Mplex": let stream = await mplexDial.newStream() var bigseq = newSeqOfCap[uint8](MaxMsgSize + 1) for _ in 0..