Add simple test for HTTP (WIP)

This commit is contained in:
coffeepots 2018-06-19 18:22:01 +01:00
parent 14009846ef
commit 49afd6ee76
1 changed files with 19 additions and 0 deletions

19
tests/testhttp.nim Normal file
View File

@ -0,0 +1,19 @@
import unittest, json, chronicles
import ../rpcclient, ../rpchttpservers
var srv = newRpcHttpServer(["localhost:8545"])
var client = newRpcClient()
# 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))
var r = waitFor client.call("myProc", %[%"abc", %[1, 2, 3, 4]])
echo r
srv.stop()
srv.close()
echo "done"