add test cases for rpc websocket client-server
This commit is contained in:
parent
b8a8ca2623
commit
ccb19734e6
|
@ -32,3 +32,26 @@ suite "Socket Server/Client RPC":
|
|||
|
||||
srv.stop()
|
||||
waitFor srv.closeWait()
|
||||
|
||||
suite "Websocket Server/Client RPC":
|
||||
var srv = newRpcWebSocketServer("127.0.0.1", Port(8545))
|
||||
var client = newRpcWebSocketClient()
|
||||
|
||||
srv.setupServer()
|
||||
srv.start()
|
||||
waitFor client.connect("ws://127.0.0.1:8545/")
|
||||
|
||||
test "Successful RPC call":
|
||||
let r = waitFor client.call("myProc", %[%"abc", %[1, 2, 3, 4]])
|
||||
check r.getStr == "Hello abc data: [1, 2, 3, 4]"
|
||||
|
||||
test "Missing params":
|
||||
expect(CatchableError):
|
||||
discard waitFor client.call("myProc", %[%"abc"])
|
||||
|
||||
test "Error RPC call":
|
||||
expect(CatchableError): # The error type wont be translated
|
||||
discard waitFor client.call("myError", %[%"abc", %[1, 2, 3, 4]])
|
||||
|
||||
srv.stop()
|
||||
waitFor srv.closeWait()
|
||||
|
|
Loading…
Reference in New Issue