forked from zcash/zcash
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better error for “wrong number of params” in RPC
Doesn’t rely on `fHelp` throwing an exception, and adds a test.
- Loading branch information
Showing
4 changed files
with
72 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,7 @@ | |
'wallet_zero_value.py', | ||
'threeofthreerestore.py', | ||
'show_help.py', | ||
'errors.py' | ||
] | ||
|
||
ZMQ_SCRIPTS = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2014-2016 The Bitcoin Core developers | ||
# Copyright (c) 2018-2023 The Zcash developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or https://www.opensource.org/licenses/mit-license.php . | ||
|
||
# | ||
# Test RPC call failure cases. Tests should mostly correspond to code in rpc/server.cpp. | ||
# | ||
|
||
from test_framework.authproxy import JSONRPCException | ||
from test_framework.test_framework import BitcoinTestFramework | ||
from test_framework.util import start_nodes | ||
|
||
class BlockchainTest(BitcoinTestFramework): | ||
""" | ||
Test RPC call failure cases. | ||
""" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.num_nodes = 2 | ||
|
||
def setup_network(self, split=False): | ||
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir) | ||
self.is_network_split = False | ||
self.sync_all() | ||
|
||
def run_test(self): | ||
node = self.nodes[0] | ||
|
||
try: | ||
node.gettxoutsetinfo(1) | ||
except JSONRPCException as e: | ||
errorString = e.error['message'] | ||
assert("Too many parameters for method `gettxoutsetinfo`. Needed exactly 0, but received 1" in errorString) | ||
|
||
if __name__ == '__main__': | ||
BlockchainTest().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters