diff --git a/tests/testasyncstream.nim b/tests/testasyncstream.nim index 61138341..34a51944 100644 --- a/tests/testasyncstream.nim +++ b/tests/testasyncstream.nim @@ -625,37 +625,58 @@ suite "TLSStream test suite": proc serveClient(server: StreamServer, transp: StreamTransport) {.async.} = + echo "server accepted client" var reader = newAsyncStreamReader(transp) var writer = newAsyncStreamWriter(transp) var sstream = newTLSServerAsyncStream(reader, writer, key, cert) + echo "server handshaking" await handshake(sstream) + echo "server handshaked" await sstream.writer.write(testMessage & "\r\n") + echo "server wrote string" await sstream.writer.closeWait() + echo "server closed secure writer" await sstream.reader.closeWait() + echo "server closed secure reader" await reader.closeWait() + echo "server closed reader" await writer.closeWait() + echo "server closed writer" await transp.closeWait() + echo "server closed transport" server.stop() + echo "server stopped server" server.close() + echo "server closed server" key = TLSPrivateKey.init(pemkey) cert = TLSCertificate.init(pemcert) var server = createStreamServer(address, serveClient, {ReuseAddr}) server.start() + echo "server started" var conn = await connect(address) + echo "client connected" var creader = newAsyncStreamReader(conn) var cwriter = newAsyncStreamWriter(conn) # We are using self-signed certificate let flags = {NoVerifyHost, NoVerifyServerName} var cstream = newTLSClientAsyncStream(creader, cwriter, "", flags = flags) + echo "client reading line" let res = await cstream.reader.readLine() + echo "client readed line" await cstream.reader.closeWait() + echo "client closed reader" await cstream.writer.closeWait() + echo "client closed writer" await creader.closeWait() + echo "client closed creader" await cwriter.closeWait() + echo "client closed cwriter" await conn.closeWait() + echo "client closed connection" await server.join() + echo "client waited server" result = res == testMessage test "Simple server with RSA self-signed certificate":