summary refs log tree commit diff stats
path: root/tests/async
diff options
context:
space:
mode:
authorMiran <narimiran@disroot.org>2020-03-25 19:15:34 +0100
committerGitHub <noreply@github.com>2020-03-25 19:15:34 +0100
commit5b55aa52d05ff911d64febc973bed1f0c2d97d25 (patch)
tree27f204241efaacd7ba138167fe7b81146e155935 /tests/async
parent182d3c16e3b7aac9ed3575dec55e6d9a3d5042c4 (diff)
downloadNim-5b55aa52d05ff911d64febc973bed1f0c2d97d25.tar.gz
fix deprecations and other warnings (#13748)
Diffstat (limited to 'tests/async')
-rw-r--r--tests/async/t6846.nim3
-rw-r--r--tests/async/tacceptcloserace.nim4
-rw-r--r--tests/async/tasyncconnect.nim2
-rw-r--r--tests/async/tasyncdial.nim2
-rw-r--r--tests/async/tioselectors.nim6
-rw-r--r--tests/async/tnewasyncudp.nim12
-rw-r--r--tests/async/twinasyncrw.nim4
7 files changed, 16 insertions, 17 deletions
diff --git a/tests/async/t6846.nim b/tests/async/t6846.nim
index 687a3f865..7fe38f3b3 100644
--- a/tests/async/t6846.nim
+++ b/tests/async/t6846.nim
@@ -6,11 +6,10 @@ discard """
 
 import asyncdispatch
 import asyncfile
-import times
 
 var asyncStdout = 1.AsyncFD.newAsyncFile()
 proc doStuff: Future[void] {.async.} =
   await asyncStdout.write "hello world\n"
 
 let fut = doStuff()
-doAssert fut.finished, "Poll is needed unnecessarily. See #6846."
\ No newline at end of file
+doAssert fut.finished, "Poll is needed unnecessarily. See #6846."
diff --git a/tests/async/tacceptcloserace.nim b/tests/async/tacceptcloserace.nim
index cbb5b5098..fee6537d2 100644
--- a/tests/async/tacceptcloserace.nim
+++ b/tests/async/tacceptcloserace.nim
@@ -8,7 +8,7 @@ import asyncdispatch, net, os, nativesockets
 # bug: https://github.com/nim-lang/Nim/issues/5279
 
 proc setupServerSocket(hostname: string, port: Port): AsyncFD =
-  let fd = newNativeSocket()
+  let fd = createNativeSocket()
   if fd == osInvalidSocket:
     raiseOSError(osLastError())
   setSockOptInt(fd, SOL_SOCKET, SO_REUSEADDR, 1)
@@ -30,7 +30,7 @@ for i in 0..100:
     if not fut.failed:
       fut.read().closeSocket()
 
-  var fd = newAsyncNativeSocket()
+  var fd = createAsyncNativeSocket()
   waitFor fd.connect("localhost", port)
   serverFd.closeSocket()
   fd.closeSocket()
diff --git a/tests/async/tasyncconnect.nim b/tests/async/tasyncconnect.nim
index f63a87990..564f6c67c 100644
--- a/tests/async/tasyncconnect.nim
+++ b/tests/async/tasyncconnect.nim
@@ -18,7 +18,7 @@ when defined(windows) or defined(nimdoc):
     quit("Error: unhandled exception: Connection refused")
 else:
     proc testAsyncConnect() {.async.} =
-        var s = newAsyncNativeSocket()
+        var s = createAsyncNativeSocket()
 
         await s.connect(testHost, testPort)
 
diff --git a/tests/async/tasyncdial.nim b/tests/async/tasyncdial.nim
index bbff7028d..a755de74e 100644
--- a/tests/async/tasyncdial.nim
+++ b/tests/async/tasyncdial.nim
@@ -13,7 +13,7 @@ proc setupServerSocket(hostname: string, port: Port, domain: Domain): AsyncFD =
   ## Creates a socket, binds it to the specified address, and starts listening for connections.
   ## Registers the descriptor with the dispatcher of the current thread
   ## Raises OSError in case of an error.
-  let fd = newNativeSocket(domain)
+  let fd = createNativeSocket(domain)
   setSockOptInt(fd, SOL_SOCKET, SO_REUSEADDR, 1)
   var aiList = getAddrInfo(hostname, port, domain)
   if bindAddr(fd, aiList.ai_addr, aiList.ai_addrlen.Socklen) < 0'i32:
diff --git a/tests/async/tioselectors.nim b/tests/async/tioselectors.nim
index e172e1452..48aa64838 100644
--- a/tests/async/tioselectors.nim
+++ b/tests/async/tioselectors.nim
@@ -13,7 +13,7 @@ template processTest(t, x: untyped) =
 when defined(macosx):
   echo "All tests passed!"
 elif not defined(windows):
-  import os, posix, nativesockets, times
+  import os, posix, nativesockets
 
   when ioselSupportedPlatform:
     import osproc
@@ -445,7 +445,7 @@ elif not defined(windows):
       var
         thr: array[0..7, Thread[SelectEvent]]
       var selector = newSelector[int]()
-      var sock = newNativeSocket()
+      var sock = createNativeSocket()
       var event = newSelectEvent()
       for i in 0..high(thr):
         createThread(thr[i], event_wait_thread, event)
@@ -475,7 +475,7 @@ else:
 
   proc socket_notification_test(): bool =
     proc create_test_socket(): SocketHandle =
-      var sock = newNativeSocket()
+      var sock = createNativeSocket()
       setBlocking(sock, false)
       result = sock
 
diff --git a/tests/async/tnewasyncudp.nim b/tests/async/tnewasyncudp.nim
index feab46319..76462c21d 100644
--- a/tests/async/tnewasyncudp.nim
+++ b/tests/async/tnewasyncudp.nim
@@ -40,9 +40,9 @@ proc launchSwarm(name: ptr SockAddr) {.async.} =
   var saddr = Sockaddr_in()
   while i < swarmSize:
     var peeraddr = prepareAddress(INADDR_LOOPBACK, 0)
-    var sock = newAsyncNativeSocket(nativesockets.AF_INET,
-                                    nativesockets.SOCK_DGRAM,
-                                    Protocol.IPPROTO_UDP)
+    var sock = createAsyncNativeSocket(nativesockets.AF_INET,
+                                       nativesockets.SOCK_DGRAM,
+                                       Protocol.IPPROTO_UDP)
     if bindAddr(sock.SocketHandle, cast[ptr SockAddr](peeraddr),
               sizeof(Sockaddr_in).Socklen) < 0'i32:
       raiseOSError(osLastError())
@@ -91,9 +91,9 @@ proc readMessages(server: AsyncFD) {.async.} =
 
 proc createServer() {.async.} =
   var name = prepareAddress(INADDR_LOOPBACK, serverPort)
-  var server = newAsyncNativeSocket(nativesockets.AF_INET,
-                                    nativesockets.SOCK_DGRAM,
-                                    Protocol.IPPROTO_UDP)
+  var server = createAsyncNativeSocket(nativesockets.AF_INET,
+                                       nativesockets.SOCK_DGRAM,
+                                       Protocol.IPPROTO_UDP)
   if bindAddr(server.SocketHandle, cast[ptr SockAddr](name),
               sizeof(Sockaddr_in).Socklen) < 0'i32:
     raiseOSError(osLastError())
diff --git a/tests/async/twinasyncrw.nim b/tests/async/twinasyncrw.nim
index db10fffce..352c53b41 100644
--- a/tests/async/twinasyncrw.nim
+++ b/tests/async/twinasyncrw.nim
@@ -208,7 +208,7 @@ when defined(windows):
 
   proc launchSwarm(port: Port) {.async.} =
     for i in 0 ..< swarmSize:
-      var sock = newNativeSocket()
+      var sock = createNativeSocket()
       setBlocking(sock, false)
 
       await winConnect(AsyncFD(sock), "localhost", port)
@@ -229,7 +229,7 @@ when defined(windows):
           doAssert false
 
   proc createServer(port: Port) {.async.} =
-    var server = newNativeSocket()
+    var server = createNativeSocket()
     setBlocking(server, false)
     block:
       var name = Sockaddr_in()