Merge pull request #34 from status-im/FixTestsNotClosingConnections

Fix tests not closing connections
This commit is contained in:
Eugene Kabanov 2018-09-13 21:51:17 +03:00 committed by GitHub
commit d469109680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 9 deletions

View File

@ -319,3 +319,8 @@ proc close*(server: RpcHttpServer) =
## Cleanup resources of RPC server.
for item in server.servers:
item.close()
proc closeWait*(server: RpcHttpServer) {.async.} =
## Cleanup resources of RPC server.
for item in server.servers:
await item.closeWait()

View File

@ -147,3 +147,8 @@ proc close*(server: RpcSocketServer) =
## Cleanup resources of RPC server.
for item in server.servers:
item.close()
proc closeWait*(server: RpcSocketServer) {.async.} =
## Cleanup resources of RPC server.
for item in server.servers:
await item.closeWait()

View File

@ -6,11 +6,11 @@
import unittest, debugclient, ../json_rpc/rpcserver
import strformat, chronicles
var server = newRpcSocketServer("localhost", 8547.Port)
var server = newRpcSocketServer("localhost", Port(8545))
var client = newRpcSocketClient()
server.start()
waitFor client.connect("localhost", Port(8547))
waitFor client.connect("localhost", Port(8545))
server.rpc("rpc") do(a: int, b: int):
result = %(&"a: {a}, b: {b}")

View File

@ -7,7 +7,7 @@ from strutils import rsplit
template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0]
var
server = newRpcSocketServer("localhost", Port(8546))
server = newRpcSocketServer("localhost", Port(8545))
client = newRpcSocketClient()
## Generate Ethereum server RPCs
@ -49,7 +49,7 @@ proc testSigCalls: Future[seq[string]] =
result = all(version, sha3)
server.start()
waitFor client.connect("localhost", Port(8546))
waitFor client.connect("localhost", Port(8545))
suite "Local calls":
@ -74,4 +74,4 @@ suite "Generated from signatures":
check sigResults[1] == "0x47173285A8D7341E5E972FC677286384F802F8EF42A5EC5F03BBFA254CB01FAD"
server.stop()
server.close()
waitFor server.closeWait()

View File

@ -177,4 +177,4 @@ suite "HTTP Server/HTTP Client RPC test suite":
check waitFor(disconTest("localhost", Port(8545), 7, 200)) == true
httpsrv.stop()
httpsrv.close()
waitFor httpsrv.closeWait()

View File

@ -157,4 +157,4 @@ suite "Server types":
check r == %"hello world"
s.stop()
s.close()
waitFor s.closeWait()

View File

@ -18,4 +18,4 @@ suite "Server/Client RPC":
check r.result.getStr == "Hello abc data: [1, 2, 3, 4]"
srv.stop()
srv.close()
waitFor srv.closeWait()