mirror of
https://github.com/status-im/nim-json-rpc.git
synced 2025-02-24 18:28:10 +00:00
Add some testing for custom rpc calls
This commit is contained in:
parent
49f2d4e32a
commit
5317300d45
@ -1,15 +1,19 @@
|
|||||||
import ../eth-rpc / rpcclient, ../eth-rpc / rpcserver, asyncdispatch, json, unittest, ../eth-rpc/server/ethprocs
|
import ../eth-rpc / rpcclient, ../eth-rpc / rpcserver,
|
||||||
|
asyncdispatch, json, unittest, tables
|
||||||
|
|
||||||
# REVIEW: I'd like to see some dummy implementations of RPC calls handled in async fashion.
|
# REVIEW: I'd like to see some dummy implementations of RPC calls handled in async fashion.
|
||||||
proc myProc {.rpc.} =
|
proc myProc* {.rpc.} =
|
||||||
return %"hello"
|
# Custom async RPC call
|
||||||
|
return %"Hello"
|
||||||
|
|
||||||
|
var srv = newRpcServer("")
|
||||||
|
# This is required to automatically register `myProc` to new servers
|
||||||
|
registerRpcs(srv)
|
||||||
|
# TODO: Avoid having to add procs twice, once for the ethprocs in newRpcServer,
|
||||||
|
# and again with the extra `myProc` rpc
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
# create on localhost, default port
|
# create on localhost, default port
|
||||||
var srv = newRpcServer("")
|
|
||||||
registerEthereumRpcs(srv)
|
|
||||||
asyncCheck srv.serve()
|
|
||||||
|
|
||||||
suite "RPC":
|
suite "RPC":
|
||||||
proc main {.async.} =
|
proc main {.async.} =
|
||||||
var client = newRpcClient()
|
var client = newRpcClient()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user