Fix datagram test from freezing.

This commit is contained in:
cheatfate 2018-10-27 19:17:37 +03:00
parent 4df91648e3
commit 14dd1e9a8e

View File

@ -139,9 +139,8 @@ proc client5(transp: DatagramTransport,
if counterPtr[] == MessagesCount:
transp.close()
else:
var ta = initTAddress("127.0.0.1:33341")
var req = "REQUEST" & $counterPtr[]
await transp.sendTo(ta, addr req[0], len(req))
await transp.sendTo(raddr, addr req[0], len(req))
else:
var counterPtr = cast[ptr int](transp.udata)
counterPtr[] = -1
@ -165,9 +164,7 @@ proc client6(transp: DatagramTransport,
var numstr = data[7..^1]
var num = parseInt(numstr)
var ans = "ANSWER" & $num
echo "Sending answer"
await transp.sendTo(raddr, ans)
echo "Answer sent"
else:
var err = "ERROR"
await transp.sendTo(raddr, err)
@ -192,11 +189,9 @@ proc client7(transp: DatagramTransport,
if counterPtr[] == TestsCount:
transp.close()
else:
var ta = initTAddress("127.0.0.1:33336")
# var ta = initTAddress("127.0.0.1:33336")
var req = "REQUEST" & $counterPtr[]
echo "Sending request"
await transp.sendTo(ta, req)
echo "Request sent"
await transp.sendTo(raddr, req)
else:
var counterPtr = cast[ptr int](transp.udata)
counterPtr[] = -1
@ -276,11 +271,11 @@ proc client10(transp: DatagramTransport,
if counterPtr[] == TestsCount:
transp.close()
else:
var ta = initTAddress("127.0.0.1:33338")
# var ta = initTAddress("127.0.0.1:33338")
var req = "REQUEST" & $counterPtr[]
var reqseq = newSeq[byte](len(req))
copyMem(addr reqseq[0], addr req[0], len(req))
await transp.sendTo(ta, reqseq)
await transp.sendTo(raddr, reqseq)
else:
var counterPtr = cast[ptr int](transp.udata)
counterPtr[] = -1
@ -346,7 +341,7 @@ proc testPointerSend(): Future[int] {.async.} =
proc testStringSendTo(): Future[int] {.async.} =
## sendTo(string) test
var ta = initTAddress("127.0.0.1:33336")
var ta = initTAddress("127.0.0.1:33338")
var counter = 0
var dgram1 = newDatagramTransport(client6, udata = addr counter, local = ta)
var dgram2 = newDatagramTransport(client7, udata = addr counter)
@ -358,7 +353,7 @@ proc testStringSendTo(): Future[int] {.async.} =
proc testStringSend(): Future[int] {.async.} =
## send(string) test
var ta = initTAddress("127.0.0.1:33337")
var ta = initTAddress("127.0.0.1:33339")
var counter = 0
var dgram1 = newDatagramTransport(client6, udata = addr counter, local = ta)
var dgram2 = newDatagramTransport(client8, udata = addr counter, remote = ta)
@ -370,7 +365,7 @@ proc testStringSend(): Future[int] {.async.} =
proc testSeqSendTo(): Future[int] {.async.} =
## sendTo(string) test
var ta = initTAddress("127.0.0.1:33338")
var ta = initTAddress("127.0.0.1:33340")
var counter = 0
var dgram1 = newDatagramTransport(client9, udata = addr counter, local = ta)
var dgram2 = newDatagramTransport(client10, udata = addr counter)
@ -384,7 +379,7 @@ proc testSeqSendTo(): Future[int] {.async.} =
proc testSeqSend(): Future[int] {.async.} =
## send(string) test
var ta = initTAddress("127.0.0.1:33339")
var ta = initTAddress("127.0.0.1:33341")
var counter = 0
var dgram1 = newDatagramTransport(client9, udata = addr counter, local = ta)
var dgram2 = newDatagramTransport(client11, udata = addr counter, remote = ta)
@ -412,9 +407,9 @@ proc waitAll(futs: seq[Future[void]]): Future[void] =
proc test3(bounded: bool): Future[int] {.async.} =
var ta: TransportAddress
if bounded:
ta = initTAddress("127.0.0.1:33340")
ta = initTAddress("127.0.0.1:33240")
else:
ta = initTAddress("127.0.0.1:33341")
ta = initTAddress("127.0.0.1:33241")
var counter = 0
var dgram1 = newDatagramTransport(client1, udata = addr counter, local = ta)
var clients = newSeq[Future[void]](ClientsCount)