summary refs log tree commit diff stats
path: root/tests/async
diff options
context:
space:
mode:
Diffstat (limited to 'tests/async')
-rw-r--r--tests/async/tasyncall.nim9
-rw-r--r--tests/async/tasyncsend4757.nim15
-rw-r--r--tests/async/tnewasyncudp.nim2
3 files changed, 18 insertions, 8 deletions
diff --git a/tests/async/tasyncall.nim b/tests/async/tasyncall.nim
index 7daecd9ef..a3926eabd 100644
--- a/tests/async/tasyncall.nim
+++ b/tests/async/tasyncall.nim
@@ -40,8 +40,7 @@ proc testVarargs(x, y, z: int): seq[int] =
 
   result = waitFor all(a, b, c)
 
-suite "tasyncall":
-  test "testFuturesWithValue":
+block:
     let
       startTime = cpuTime()
       results = testFuturesWithValue(42)
@@ -51,14 +50,14 @@ suite "tasyncall":
     doAssert execTime * 1000 < taskCount * sleepDuration
     doAssert results == expected
 
-  test "testFuturesWithoutValues":
+block:
     let startTime = cpuTime()
     testFuturesWithoutValues()
     let execTime = cpuTime() - startTime
 
     doAssert execTime * 1000 < taskCount * sleepDuration
 
-  test "testVarargs":
+block:
     let
       startTime = cpuTime()
       results = testVarargs(1, 2, 3)
@@ -68,7 +67,7 @@ suite "tasyncall":
     doAssert execTime * 100 < taskCount * sleepDuration
     doAssert results == expected
 
-  test "all on seq[Future]":
+block:
     let
       noIntFuturesFut = all(newSeq[Future[int]]())
       noVoidFuturesFut = all(newSeq[Future[void]]())
diff --git a/tests/async/tasyncsend4757.nim b/tests/async/tasyncsend4757.nim
index 1066f38e5..752bb3e75 100644
--- a/tests/async/tasyncsend4757.nim
+++ b/tests/async/tasyncsend4757.nim
@@ -3,11 +3,22 @@ discard """
   output: "Finished"
 """
 
-import asyncdispatch
+import asyncdispatch, asyncnet
+
+proc createServer(port: Port) {.async.} =
+  var server = newAsyncSocket()
+  server.setSockOpt(OptReuseAddr, true)
+  bindAddr(server, port)
+  server.listen()
+  while true:
+    let client = await server.accept()
+    discard await client.recvLine()
+
+asyncCheck createServer(10335.Port)
 
 proc f(): Future[void] {.async.} =
   let s = newAsyncNativeSocket()
-  await s.connect("example.com", 80.Port)
+  await s.connect("localhost", 10335.Port)
   await s.send("123")
   echo "Finished"
 
diff --git a/tests/async/tnewasyncudp.nim b/tests/async/tnewasyncudp.nim
index b56cdc71b..e61f630e4 100644
--- a/tests/async/tnewasyncudp.nim
+++ b/tests/async/tnewasyncudp.nim
@@ -86,7 +86,7 @@ proc readMessages(server: AsyncFD) {.async.} =
     size = 0
     var grammString = $cstring(addr buffer)
     if grammString.startswith("Message ") and
-       saddr.sin_addr.s_addr == 0x100007F:
+       saddr.sin_addr.s_addr == nativesockets.ntohl(INADDR_LOOPBACK.uint32):
       await sendTo(server, addr grammString[0], len(grammString),
                    cast[ptr SockAddr](addr saddr), slen)
       inc(msgCount)