reduce compiler warnings
This commit is contained in:
parent
c0ecb42613
commit
38950a786d
|
@ -96,7 +96,7 @@ jobs:
|
|||
- name: Restore Nim DLLs dependencies (Windows) from cache
|
||||
if: runner.os == 'Windows'
|
||||
id: windows-dlls-cache
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: external/dlls-${{ matrix.target.cpu }}
|
||||
key: 'dlls-${{ matrix.target.cpu }}'
|
||||
|
@ -156,6 +156,9 @@ jobs:
|
|||
nim --version
|
||||
nimble --version
|
||||
nimble install -y --depsOnly
|
||||
# remove nimble.lock and allow nim 1.2 to nim devel have the same behaviour
|
||||
# when compiling
|
||||
rm -f nimble.lock
|
||||
env TEST_LANG="c" nimble test
|
||||
# C++ is unsupported: https://github.com/status-im/nim-json-rpc/issues/119
|
||||
#env TEST_LANG="cpp" nimble test
|
||||
|
|
|
@ -20,3 +20,5 @@ nimcache/
|
|||
|
||||
nimble.develop
|
||||
nimble.paths
|
||||
|
||||
/vendor
|
||||
|
|
|
@ -82,8 +82,13 @@ proc createRpcProc(procName, parameters, callBody: NimNode): NimNode =
|
|||
var paramList = newSeq[NimNode]()
|
||||
for p in parameters: paramList.add(p)
|
||||
|
||||
let body = quote do:
|
||||
{.gcsafe.}:
|
||||
`callBody`
|
||||
|
||||
# build proc
|
||||
result = newProc(procName, paramList, callBody)
|
||||
result = newProc(procName, paramList, body)
|
||||
|
||||
# make proc async
|
||||
result.addPragma ident"async"
|
||||
# export this proc
|
||||
|
@ -138,8 +143,6 @@ proc createRpcFromSig*(clientType, rpcDecl: NimNode): NimNode =
|
|||
|
||||
# convert return type to Future
|
||||
parameters[0] = nnkBracketExpr.newTree(ident"Future", returnType)
|
||||
# create rpc proc
|
||||
result = createRpcProc(procName, parameters, callBody)
|
||||
|
||||
let
|
||||
# temporary variable to hold `Response` from rpc call
|
||||
|
@ -165,6 +168,8 @@ proc createRpcFromSig*(clientType, rpcDecl: NimNode): NimNode =
|
|||
else:
|
||||
`rpcResult`
|
||||
|
||||
# create rpc proc
|
||||
result = createRpcProc(procName, parameters, callBody)
|
||||
when defined(nimDumpRpcs):
|
||||
echo pathStr, ":\n", result.repr
|
||||
|
||||
|
|
|
@ -150,7 +150,8 @@ proc unpackArg[T](args: JsonNode, argName: string, argtype: typedesc[T]): T =
|
|||
mixin fromJson
|
||||
if args == nil:
|
||||
raise (ref ValueError)(msg: argName & ": unexpected null value")
|
||||
fromJson(args, argName, result)
|
||||
{.gcsafe.}:
|
||||
fromJson(args, argName, result)
|
||||
|
||||
proc expectArrayLen(node, jsonIdent: NimNode, length: int) =
|
||||
let
|
||||
|
|
|
@ -34,7 +34,7 @@ proc newRpcRouter*: RpcRouter {.deprecated.} =
|
|||
RpcRouter.init()
|
||||
|
||||
proc register*(router: var RpcRouter, path: string, call: RpcProc) =
|
||||
router.procs.add(path, call)
|
||||
router.procs[path] = call
|
||||
|
||||
proc clear*(router: var RpcRouter) =
|
||||
router.procs.clear
|
||||
|
@ -90,6 +90,9 @@ proc route*(router: RpcRouter, node: JsonNode): Future[StringOfJson] {.async, gc
|
|||
proc route*(router: RpcRouter, data: string): Future[string] {.async, gcsafe.} =
|
||||
## Route to RPC from string data. Data is expected to be able to be converted to Json.
|
||||
## Returns string of Json from RPC result/error node
|
||||
when (NimMajor, NimMinor) >= (1, 6):
|
||||
{.warning[BareExcept]:off.}
|
||||
|
||||
let node =
|
||||
try: parseJson(data)
|
||||
except CatchableError as err:
|
||||
|
@ -98,6 +101,9 @@ proc route*(router: RpcRouter, data: string): Future[string] {.async, gcsafe.} =
|
|||
# TODO https://github.com/status-im/nimbus-eth2/issues/2430
|
||||
return string(wrapError(JSON_PARSE_ERROR, err.msg))
|
||||
|
||||
when (NimMajor, NimMinor) >= (1, 6):
|
||||
{.warning[BareExcept]:on.}
|
||||
|
||||
return string(await router.route(node))
|
||||
|
||||
proc tryRoute*(router: RpcRouter, data: JsonNode, fut: var Future[StringOfJson]): bool =
|
||||
|
|
|
@ -58,13 +58,17 @@ proc addStreamServer*(server: RpcSocketServer, address: string) =
|
|||
# Attempt to resolve `address` for IPv4 address space.
|
||||
try:
|
||||
tas4 = resolveTAddress(address, AddressFamily.IPv4)
|
||||
except:
|
||||
except CatchableError:
|
||||
discard
|
||||
except Defect:
|
||||
discard
|
||||
|
||||
# Attempt to resolve `address` for IPv6 address space.
|
||||
try:
|
||||
tas6 = resolveTAddress(address, AddressFamily.IPv6)
|
||||
except:
|
||||
except CatchableError:
|
||||
discard
|
||||
except Defect:
|
||||
discard
|
||||
|
||||
for r in tas4:
|
||||
|
@ -91,13 +95,17 @@ proc addStreamServer*(server: RpcSocketServer, address: string, port: Port) =
|
|||
# Attempt to resolve `address` for IPv4 address space.
|
||||
try:
|
||||
tas4 = resolveTAddress(address, port, AddressFamily.IPv4)
|
||||
except:
|
||||
except CatchableError:
|
||||
discard
|
||||
except Defect:
|
||||
discard
|
||||
|
||||
# Attempt to resolve `address` for IPv6 address space.
|
||||
try:
|
||||
tas6 = resolveTAddress(address, port, AddressFamily.IPv6)
|
||||
except:
|
||||
except CatchableError:
|
||||
discard
|
||||
except Defect:
|
||||
discard
|
||||
|
||||
if len(tas4) == 0 and len(tas6) == 0:
|
||||
|
|
84
nimble.lock
84
nimble.lock
|
@ -2,53 +2,56 @@
|
|||
"version": 1,
|
||||
"packages": {
|
||||
"unittest2": {
|
||||
"version": "0.0.4",
|
||||
"vcsRevision": "f180f596c88dfd266f746ed6f8dbebce39c824db",
|
||||
"version": "0.0.6",
|
||||
"vcsRevision": "883c7a50ad3b82158e64d074c5578fe33ab3c452",
|
||||
"url": "https://github.com/status-im/nim-unittest2.git",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [],
|
||||
"checksums": {
|
||||
"sha1": "fa309c41eaf6ef57895b9e603f2620a2f6e11780"
|
||||
"sha1": "540e3959bd489b423dcd7d5f6373fa43153c35c8"
|
||||
}
|
||||
},
|
||||
"stew": {
|
||||
"version": "0.1.0",
|
||||
"vcsRevision": "6ad35b876fb6ebe0dfee0f697af173acc47906ee",
|
||||
"url": "https://github.com/status-im/nim-stew.git",
|
||||
"vcsRevision": "e18f5a62af2ade7a1fd1d39635d4e04d944def08",
|
||||
"url": "https://github.com/status-im/nim-stew",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [],
|
||||
"dependencies": [
|
||||
"unittest2"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "46d58c4feb457f3241e3347778334e325dce5268"
|
||||
"sha1": "2a80972f66597bf87d820dca8164d89d3bb24c6d"
|
||||
}
|
||||
},
|
||||
"bearssl": {
|
||||
"version": "0.1.5",
|
||||
"vcsRevision": "ba80e2a0d7ae8aab666cee013e38ff8d33a3e5e7",
|
||||
"version": "0.2.0",
|
||||
"vcsRevision": "acf9645e328bdcab481cfda1c158e07ecd46bd7b",
|
||||
"url": "https://github.com/status-im/nim-bearssl",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"unittest2"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "383abd5becc77bf8e365b780a29d20529e1d9c4c"
|
||||
"sha1": "c939aef6a1c17c95131242a6292ade1c92380792"
|
||||
}
|
||||
},
|
||||
"httputils": {
|
||||
"version": "0.3.0",
|
||||
"vcsRevision": "689da19e9e9cfff4ced85e2b25c6b2b5598ed079",
|
||||
"url": "https://github.com/status-im/nim-http-utils.git",
|
||||
"vcsRevision": "a85bd52ae0a956983ca6b3267c72961d2ec0245f",
|
||||
"url": "https://github.com/status-im/nim-http-utils",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"stew"
|
||||
"stew",
|
||||
"unittest2"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "4ad3ad68d13c50184180ab4b2eacc0bd7ed2ed44"
|
||||
"sha1": "92933b21bcd29335f68e377e2b2193fa331e28b3"
|
||||
}
|
||||
},
|
||||
"chronos": {
|
||||
"version": "3.0.11",
|
||||
"vcsRevision": "17fed89c99beac5a92d3668d0d3e9b0e4ac13936",
|
||||
"url": "https://github.com/status-im/nim-chronos.git",
|
||||
"vcsRevision": "1b69b5e8081e6afb748b401f4e28db6056a53c9a",
|
||||
"url": "https://github.com/status-im/nim-chronos",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"stew",
|
||||
|
@ -57,7 +60,7 @@
|
|||
"unittest2"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "f6fffc87571e5f76af2a77c4ebcc0e00909ced4e"
|
||||
"sha1": "4b98807facae395df73335c8e089623370ed50bc"
|
||||
}
|
||||
},
|
||||
"testutils": {
|
||||
|
@ -74,23 +77,22 @@
|
|||
},
|
||||
"faststreams": {
|
||||
"version": "0.3.0",
|
||||
"vcsRevision": "1b561a9e71b6bdad1c1cdff753418906037e9d09",
|
||||
"url": "https://github.com/status-im/nim-faststreams.git",
|
||||
"vcsRevision": "814f8927e1f356f39219f37f069b83066bcc893a",
|
||||
"url": "https://github.com/status-im/nim-faststreams",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"stew",
|
||||
"testutils",
|
||||
"chronos",
|
||||
"unittest2"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "97edf9797924af48566a0af8267203dc21d80c77"
|
||||
"sha1": "16c69a7b454d803dcf28f6115f42bb47421d9376"
|
||||
}
|
||||
},
|
||||
"serialization": {
|
||||
"version": "0.1.0",
|
||||
"vcsRevision": "fcd0eadadde0ee000a63df8ab21dc4e9f015a790",
|
||||
"url": "https://github.com/status-im/nim-serialization.git",
|
||||
"vcsRevision": "5b7cea55efeb074daa8abd8146a03a34adb4521a",
|
||||
"url": "https://github.com/status-im/nim-serialization",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"faststreams",
|
||||
|
@ -98,33 +100,33 @@
|
|||
"stew"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "fef59519892cac70cccd81b612085caaa5e3e6cf"
|
||||
"sha1": "433ee95c167fa9f8a4d6691d5e0e8d6b5d8516a6"
|
||||
}
|
||||
},
|
||||
"json_serialization": {
|
||||
"version": "0.1.0",
|
||||
"vcsRevision": "c5f0e2465e8375dfc7aa0f56ccef67cb680bc6b0",
|
||||
"url": "https://github.com/status-im/nim-json-serialization.git",
|
||||
"vcsRevision": "a7d815ed92f200f490c95d3cfd722089cc923ce6",
|
||||
"url": "https://github.com/status-im/nim-json-serialization",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"serialization",
|
||||
"stew"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "d89d79d0679a3a41b350e3ad4be56c0308cc5ec6"
|
||||
"sha1": "50fc34a992ef3df68a7bee88af096bb8ed42572f"
|
||||
}
|
||||
},
|
||||
"chronicles": {
|
||||
"version": "0.10.2",
|
||||
"vcsRevision": "1682096306ddba8185dcfac360a8c3f952d721e4",
|
||||
"url": "https://github.com/status-im/nim-chronicles.git",
|
||||
"version": "0.10.3",
|
||||
"vcsRevision": "12f5621c90942bb531c8486bfa3711e88adbe015",
|
||||
"url": "https://github.com/status-im/nim-chronicles",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"testutils",
|
||||
"json_serialization"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "9a5bebb76b0f7d587a31e621d260119279e91c76"
|
||||
"sha1": "30128b8183de5f043bb3fa5c507a4e8bad7d738e"
|
||||
}
|
||||
},
|
||||
"asynctest": {
|
||||
|
@ -149,14 +151,14 @@
|
|||
},
|
||||
"zlib": {
|
||||
"version": "0.1.0",
|
||||
"vcsRevision": "74cdeb54b21bededb5a515d36f608bc1850555a2",
|
||||
"vcsRevision": "826e2fc013f55b4478802d4f2e39f187c50d520a",
|
||||
"url": "https://github.com/status-im/nim-zlib",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"stew"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "01d330dc4c1924e56b1559ee73bc760e526f635c"
|
||||
"sha1": "6148e06a83c01425af4b63050ee81bed1bae1491"
|
||||
}
|
||||
},
|
||||
"websock": {
|
||||
|
@ -178,26 +180,16 @@
|
|||
"sha1": "ec2b137543f280298ca48de9ed4461a033ba88d3"
|
||||
}
|
||||
},
|
||||
"news": {
|
||||
"version": "0.5",
|
||||
"vcsRevision": "e79420e835489132aaa412f993b565f5dd6295f4",
|
||||
"url": "https://github.com/status-im/news",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [],
|
||||
"checksums": {
|
||||
"sha1": "a5f1789bf650822156712fd3bdec1bf6ab4ac42e"
|
||||
}
|
||||
},
|
||||
"stint": {
|
||||
"version": "0.0.1",
|
||||
"vcsRevision": "036c71d06a6b22f8f967ba9d54afd2189c3872ca",
|
||||
"url": "https://github.com/status-im/stint.git",
|
||||
"vcsRevision": "3472a16fbc38bcc25f7cc81cef040ad1ea01ccb8",
|
||||
"url": "https://github.com/status-im/nim-stint",
|
||||
"downloadMethod": "git",
|
||||
"dependencies": [
|
||||
"stew"
|
||||
],
|
||||
"checksums": {
|
||||
"sha1": "0f187a2115315ca898e5f9a30c5e506cf6057062"
|
||||
"sha1": "26322729cca4ac398bd9119b0c8407c846e1b556"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import
|
||||
unittest2, chronicles,
|
||||
unittest2,
|
||||
../json_rpc/[rpcclient, rpcserver]
|
||||
|
||||
# Create RPC on server
|
||||
|
|
Loading…
Reference in New Issue