mirror of
https://github.com/status-im/nim-json-rpc.git
synced 2025-02-24 18:28:10 +00:00
More error checking (WIP)
This commit is contained in:
parent
b632cbfb25
commit
09b55a5b32
@ -45,24 +45,36 @@ suite "RPC Errors":
|
||||
# Note: We don't expect a exceptions for most of the tests,
|
||||
# because the server should respond with the error in json
|
||||
test "Missing RPC":
|
||||
expect ValueError:
|
||||
#expect ValueError:
|
||||
try:
|
||||
let res = waitFor testMissingRpc()
|
||||
check res.error == true and
|
||||
res.result["message"] == %"Method not found" and
|
||||
res.result["data"] == %"phantomRpc is not a registered method."
|
||||
except:
|
||||
echo "Error ", getCurrentExceptionMsg()
|
||||
|
||||
test "Incorrect json version":
|
||||
expect ValueError:
|
||||
#expect ValueError:
|
||||
try:
|
||||
let res = waitFor testInvalidJsonVer()
|
||||
check res.error == true and res.result["message"] == %"JSON 2.0 required"
|
||||
except:
|
||||
echo "Error ", getCurrentExceptionMsg()
|
||||
|
||||
test "Raising exceptions":
|
||||
expect ValueError:
|
||||
#expect ValueError:
|
||||
try:
|
||||
let res = waitFor testRaise()
|
||||
except:
|
||||
echo "Error ", getCurrentExceptionMsg()
|
||||
|
||||
test "Malformed json":
|
||||
# TODO: We time out here because the server won't be able to
|
||||
# find an id to return to us, so we cannot complete the future.
|
||||
let res = waitFor testMalformed()
|
||||
check res.error == true and res.result == %"Timeout"
|
||||
try:
|
||||
let res = waitFor testMalformed()
|
||||
check res.error == true and res.result == %"Timeout"
|
||||
except:
|
||||
echo "Error ", getCurrentExceptionMsg()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user