Added testing, uses http client and server
This commit is contained in:
parent
9e8121b405
commit
d36da9d14c
|
@ -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"
|
Loading…
Reference in New Issue