mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-08-05 22:44:50 +02:00
Merge #21718: rpc: Improve error message for getblock invalid datatype.
a411494261
rpc: Improve getblock error message for invalid data type. (klementtan) Pull request description: Improve error messages for getblock invalid datatype. fixes: #21717 ACKs for top commit: instagibbs: utACKa411494261
theStack: ACKa411494261
promag: Code review ACKa411494261
. Tree-SHA512: 6e7d8290681e8ab375629f81669d0f8e0c21f9eb7ed9e2455cd19ea013e69b2d95fa7a9ee795315b2d5c60c96035c6cefc3d6e1039a06fd88c1dc7fe275ee6a1
This commit is contained in:
commit
a47ae618a0
@ -955,10 +955,11 @@ static RPCHelpMan getblock()
|
|||||||
|
|
||||||
int verbosity = 1;
|
int verbosity = 1;
|
||||||
if (!request.params[1].isNull()) {
|
if (!request.params[1].isNull()) {
|
||||||
if(request.params[1].isNum())
|
if (request.params[1].isBool()) {
|
||||||
verbosity = request.params[1].get_int();
|
|
||||||
else
|
|
||||||
verbosity = request.params[1].get_bool() ? 1 : 0;
|
verbosity = request.params[1].get_bool() ? 1 : 0;
|
||||||
|
} else {
|
||||||
|
verbosity = request.params[1].get_int();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CBlock block;
|
CBlock block;
|
||||||
|
@ -410,6 +410,9 @@ class BlockchainTest(BitcoinTestFramework):
|
|||||||
self.log.info("Test that getblock with verbosity 2 still works with pruned Undo data")
|
self.log.info("Test that getblock with verbosity 2 still works with pruned Undo data")
|
||||||
datadir = get_datadir_path(self.options.tmpdir, 0)
|
datadir = get_datadir_path(self.options.tmpdir, 0)
|
||||||
|
|
||||||
|
self.log.info("Test that getblock with invalid verbosity type returns proper error message")
|
||||||
|
assert_raises_rpc_error(-1, "JSON value is not an integer as expected", node.getblock, blockhash, "2")
|
||||||
|
|
||||||
def move_block_file(old, new):
|
def move_block_file(old, new):
|
||||||
old_path = os.path.join(datadir, self.chain, 'blocks', old)
|
old_path = os.path.join(datadir, self.chain, 'blocks', old)
|
||||||
new_path = os.path.join(datadir, self.chain, 'blocks', new)
|
new_path = os.path.join(datadir, self.chain, 'blocks', new)
|
||||||
|
Loading…
Reference in New Issue
Block a user