aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthew Zipkin <pinheadmz@gmail.com>2023-07-07 14:41:23 -0400
committerMatthew Zipkin <pinheadmz@gmail.com>2024-05-14 11:15:54 -0400
commitbf1a1f1662427fbf1a43bb951364eface469bdb7 (patch)
tree40c6da6c106ed68bf368cc2e52496f492866c563 /test
parent466b90562f4785de74b548f7c4a256069e2aaf43 (diff)
downloadbitcoin-bf1a1f1662427fbf1a43bb951364eface469bdb7.tar.xz
rpc: Avoid returning HTTP errors for JSON-RPC 2.0 requests
Avoid returning HTTP status errors for non-batch JSON-RPC 2.0 requests if the RPC method failed but the HTTP request was otherwise valid. Batch requests already did not return HTTP errors previously.
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/interface_rpc.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/functional/interface_rpc.py b/test/functional/interface_rpc.py
index dc9fb5d40f..824a7200cd 100755
--- a/test/functional/interface_rpc.py
+++ b/test/functional/interface_rpc.py
@@ -188,9 +188,9 @@ class RPCInterfaceTest(BitcoinTestFramework):
self.log.info("Testing HTTP status codes for JSON-RPC 2.0 requests...")
# OK
expect_http_rpc_status(200, None, self.nodes[0], "getblockhash", [0], 2, False)
- # RPC errors and HTTP errors
- expect_http_rpc_status(404, RPC_METHOD_NOT_FOUND, self.nodes[0], "invalidmethod", [], 2, False)
- expect_http_rpc_status(500, RPC_INVALID_PARAMETER, self.nodes[0], "getblockhash", [42], 2, False)
+ # RPC errors but not HTTP errors
+ expect_http_rpc_status(200, RPC_METHOD_NOT_FOUND, self.nodes[0], "invalidmethod", [], 2, False)
+ expect_http_rpc_status(200, RPC_INVALID_PARAMETER, self.nodes[0], "getblockhash", [42], 2, False)
# force-send invalidly formatted requests
response, status = send_json_rpc(self.nodes[0], {"jsonrpc": 2, "method": "getblockcount"})
assert_equal(response, {"id": None, "result": None, "error": {"code": RPC_INVALID_REQUEST, "message": "jsonrpc field must be a string"}})
@@ -212,7 +212,7 @@ class RPCInterfaceTest(BitcoinTestFramework):
expect_http_rpc_status(200, None, self.nodes[0], "generatetoaddress", [1, "bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdku202"], 2, True)
# The command worked even though there was no response
assert_equal(block_count + 1, self.nodes[0].getblockcount())
- expect_http_rpc_status(500, RPC_INVALID_ADDRESS_OR_KEY, self.nodes[0], "generatetoaddress", [1, "invalid_address"], 2, True)
+ expect_http_rpc_status(200, RPC_INVALID_ADDRESS_OR_KEY, self.nodes[0], "generatetoaddress", [1, "invalid_address"], 2, True)
# Sanity check: command was not executed
assert_equal(block_count + 1, self.nodes[0].getblockcount())