Added testing, uses http client and server

This commit is contained in:
coffeepots 2018-06-26 15:45:40 +01:00
parent 9e8121b405
commit d36da9d14c
1 changed files with 9 additions and 7 deletions

View File

@ -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"