mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-01-05 23:23:12 +00:00
Add close() procedure for RpcServer.
Fixed tests to stop/close server.
This commit is contained in:
parent
cbfe945fff
commit
aea1798897
@ -165,6 +165,11 @@ proc stop*(server: RpcServer) =
|
|||||||
for item in server.servers:
|
for item in server.servers:
|
||||||
item.stop()
|
item.stop()
|
||||||
|
|
||||||
|
proc close*(server: RpcServer) =
|
||||||
|
## Cleanup resources of RPC server.
|
||||||
|
for item in server.servers:
|
||||||
|
item.close()
|
||||||
|
|
||||||
# Server registration and RPC generation
|
# Server registration and RPC generation
|
||||||
|
|
||||||
proc register*(server: RpcServer, name: string, rpc: RpcProc) =
|
proc register*(server: RpcServer, name: string, rpc: RpcProc) =
|
||||||
|
|||||||
@ -72,3 +72,6 @@ suite "Generated from signatures":
|
|||||||
check sigResults[0] == "Nimbus-RPC-Test"
|
check sigResults[0] == "Nimbus-RPC-Test"
|
||||||
test "SHA3":
|
test "SHA3":
|
||||||
check sigResults[1] == "0x47173285A8D7341E5E972FC677286384F802F8EF42A5EC5F03BBFA254CB01FAD"
|
check sigResults[1] == "0x47173285A8D7341E5E972FC677286384F802F8EF42A5EC5F03BBFA254CB01FAD"
|
||||||
|
|
||||||
|
server.stop()
|
||||||
|
server.close()
|
||||||
|
|||||||
@ -132,3 +132,6 @@ suite "Server types":
|
|||||||
# wrong param type
|
# wrong param type
|
||||||
let res = waitFor rpcDifferentParams(%[%"abc", %1])
|
let res = waitFor rpcDifferentParams(%[%"abc", %1])
|
||||||
# TODO: When errors are proper return values, check error for param name
|
# TODO: When errors are proper return values, check error for param name
|
||||||
|
|
||||||
|
s.stop()
|
||||||
|
s.close()
|
||||||
@ -15,4 +15,7 @@ waitFor client.connect("localhost", Port(8545))
|
|||||||
suite "Server/Client RPC":
|
suite "Server/Client RPC":
|
||||||
test "Custom RPC":
|
test "Custom RPC":
|
||||||
var r = waitFor client.call("myProc", %[%"abc", %[1, 2, 3, 4]])
|
var r = waitFor client.call("myProc", %[%"abc", %[1, 2, 3, 4]])
|
||||||
check r.result.getStr == "Hello abc data: [1, 2, 3, 4]"
|
check r.result.getStr == "Hello abc data: [1, 2, 3, 4]"
|
||||||
|
|
||||||
|
srv.stop()
|
||||||
|
srv.close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user