fix #14320 (tasyncawait.nim is recently very flaky) + avoid hardcoding service ports everywhere + flakyAssert (#14327)
* hotfix #14320 tasyncawait.nim is recently very flaky * fix #14327 * add flakyAssert
This commit is contained in:
parent
9acbf99efb
commit
1648f1dd99
10 changed files with 102 additions and 92 deletions
12
testament/lib/stdtest/netutils.nim
Normal file
12
testament/lib/stdtest/netutils.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import std/[nativesockets, asyncdispatch, os]
|
||||
|
||||
proc bindAvailablePort*(handle: SocketHandle, port = Port(0)): Port =
|
||||
block:
|
||||
var name: Sockaddr_in
|
||||
name.sin_family = typeof(name.sin_family)(toInt(AF_INET))
|
||||
name.sin_port = htons(uint16(port))
|
||||
name.sin_addr.s_addr = htonl(INADDR_ANY)
|
||||
if bindAddr(handle, cast[ptr SockAddr](addr(name)),
|
||||
sizeof(name).Socklen) < 0'i32:
|
||||
raiseOSError(osLastError())
|
||||
result = getLocalAddr(handle, AF_INET)[1]
|
||||
Loading…
Add table
Add a link
Reference in a new issue