From 0ea8e65b2c72f1a78ce975128421876ccde62b92 Mon Sep 17 00:00:00 2001 From: cheatfate Date: Thu, 25 Oct 2018 13:52:56 +0300 Subject: [PATCH] Fix connection refused check. --- tests/teststream.nim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/teststream.nim b/tests/teststream.nim index dfbcdea8..7a1d515c 100644 --- a/tests/teststream.nim +++ b/tests/teststream.nim @@ -614,13 +614,12 @@ proc testConnectionRefused(address: TransportAddress): Future[bool] {.async.} = try: var transp = await connect(address) except TransportOsError as e: + let ecode = int(e.code) when defined(windows): - if address.family == AddressFamily.Unix: - result = (int(e.code) == ERROR_FILE_NOT_FOUND) - else: - result = (int(e.code) == ERROR_CONNECTION_REFUSED) + result = (ecode == ERROR_FILE_NOT_FOUND) or + (ecode == ERROR_CONNECTION_REFUSED) else: - result = (int(e.code) == ECONNREFUSED) + result = (ecode == ECONNREFUSED) or (ecode == ENOENT) when isMainModule: const