mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-05-18 08:29:28 +00:00
Re-add serve
This commit is contained in:
parent
e304abae2d
commit
d280dcf5aa
@ -9,9 +9,9 @@ proc myProc* {.rpc.} =
|
|||||||
var srv = newRpcServer("")
|
var srv = newRpcServer("")
|
||||||
# This is required to automatically register `myProc` to new servers
|
# This is required to automatically register `myProc` to new servers
|
||||||
registerRpcs(srv)
|
registerRpcs(srv)
|
||||||
|
asyncCheck srv.serve
|
||||||
# TODO: Avoid having to add procs twice, once for the ethprocs in newRpcServer,
|
# TODO: Avoid having to add procs twice, once for the ethprocs in newRpcServer,
|
||||||
# and again with the extra `myProc` rpc
|
# and again with the extra `myProc` rpc
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
# create on localhost, default port
|
# create on localhost, default port
|
||||||
suite "RPC":
|
suite "RPC":
|
||||||
@ -26,8 +26,10 @@ when isMainModule:
|
|||||||
test "SHA3":
|
test "SHA3":
|
||||||
response = waitFor client.web3_sha3(%"abc")
|
response = waitFor client.web3_sha3(%"abc")
|
||||||
check response.result.getStr == "3A985DA74FE225B2045C172D6BD390BD855F086E3E9D525B46BFE24511431532"
|
check response.result.getStr == "3A985DA74FE225B2045C172D6BD390BD855F086E3E9D525B46BFE24511431532"
|
||||||
response = waitFor client.call("myProc", %"abc")
|
test "Custom RPC":
|
||||||
echo response.result.getStr
|
response = waitFor client.call("myProc", %"abc")
|
||||||
|
check response.result.getStr == "Hello"
|
||||||
|
|
||||||
|
|
||||||
waitFor main()
|
waitFor main()
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user