diff --git a/eth-rpc/server/servertypes.nim b/eth-rpc/server/servertypes.nim index c51b48a..edba4a6 100644 --- a/eth-rpc/server/servertypes.nim +++ b/eth-rpc/server/servertypes.nim @@ -1,4 +1,5 @@ import asyncdispatch, asyncnet, json, tables, macros, strutils +export asyncdispatch, asyncnet, json type RpcProc* = proc (params: JsonNode): Future[JsonNode] @@ -78,51 +79,65 @@ macro multiRemove(s: string, values: varargs[string]): untyped = macro on*(server: var RpcServer, path: string, body: untyped): untyped = var paramTemplates = newStmtList() - # process parameters of body into templates let parameters = body.findChild(it.kind == nnkFormalParams) if not parameters.isNil: - # marshall result to json + # process parameters of body into json fetch templates var resType = parameters[0] if resType.kind != nnkEmpty: # TODO: transform result type and/or return to json discard - # convert input parameters to json fetch templates + # for i in 1.. int: echo "hello2" s.on("the/path3"): echo "hello3" - assert s.procs.hasKey("the/path") - assert s.procs.hasKey("the/path2") - assert s.procs.hasKey("the/path3") + result = %1 + suite "Server types": + test "On macro registration": + check s.procs.hasKey("the/path") + check s.procs.hasKey("the/path2") + check s.procs.hasKey("the/path3")