diff --git a/tests/testserverclient.nim b/tests/testserverclient.nim index 6b2c245..ba525c0 100644 --- a/tests/testserverclient.nim +++ b/tests/testserverclient.nim @@ -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()