From d36da9d14c27ec49c4e13d9dcd8142812c413f6f Mon Sep 17 00:00:00 2001 From: coffeepots Date: Tue, 26 Jun 2018 15:45:40 +0100 Subject: [PATCH] Added testing, uses http client and server --- tests/testhttp.nim | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/testhttp.nim b/tests/testhttp.nim index 86e1f90..e504ac5 100644 --- a/tests/testhttp.nim +++ b/tests/testhttp.nim @@ -1,19 +1,21 @@ -import unittest, json, chronicles -import ../rpcclient, ../rpchttpservers +import unittest, json, chronicles, unittest +import ../rpchttpservers var srv = newRpcHttpServer(["localhost:8545"]) -var client = newRpcStreamClient() +var client = newRpcHttpClient() # Create RPC on server srv.rpc("myProc") do(input: string, data: array[0..3, int]): result = %("Hello " & input & " data: " & $data) srv.start() -waitFor client.connect("localhost", Port(8545)) +waitFor client.httpConnect("localhost", Port(8545)) -var r = waitFor client.call("myProc", %[%"abc", %[1, 2, 3, 4]]) -echo r +suite "HTTP RPC transport": + test "Call": + var r = waitFor client.httpcall("myProc", %[%"abc", %[1, 2, 3, 4]]) + check r.error == false and r.result == %"Hello abc data: [1, 2, 3, 4]" -srv.stop() +srv.stop() srv.close() echo "done" \ No newline at end of file