mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-25 06:55:32 +01:00
Merge bitcoin/bitcoin#23755: rpc: Quote user supplied strings in error messages
fa24a3df87rpc: Quote user supplied strings in error messages (MarcoFalke) Pull request description: I can't see a downside doing this and this fixes a fuzzing crash Background: This is a follow-up to commit926fc2a0d4, which introduced the "starts_with-hack". Maybe an alternative to the hack would be to assign a unique error code to internal bugs? However, I think this can be done in an separate pull request and the changes here make sense even on their own. ACKs for top commit: fanquake: ACKfa24a3df87- to fix the fuzzers. Tree-SHA512: d998626406a64396a037a6d1fce22fce3dadb7567c2f9638e450ebe8fb8ae77d134e15dd02555326732208f698d77b0028bc62be9ceee9c43282b61fe95fccbd
This commit is contained in:
@@ -329,7 +329,7 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
assert 'muhash' not in r
|
||||
|
||||
# Unknown hash_type raises an error
|
||||
assert_raises_rpc_error(-8, "foohash is not a valid hash_type", node.gettxoutsetinfo, "foohash")
|
||||
assert_raises_rpc_error(-8, "'foo hash' is not a valid hash_type", node.gettxoutsetinfo, "foo hash")
|
||||
|
||||
def _test_getblockheader(self):
|
||||
self.log.info("Test getblockheader")
|
||||
|
||||
@@ -142,17 +142,17 @@ class GetblockstatsTest(BitcoinTestFramework):
|
||||
inv_sel_stat = 'asdfghjkl'
|
||||
inv_stats = [
|
||||
[inv_sel_stat],
|
||||
['minfee' , inv_sel_stat],
|
||||
['minfee', inv_sel_stat],
|
||||
[inv_sel_stat, 'minfee'],
|
||||
['minfee', inv_sel_stat, 'maxfee'],
|
||||
]
|
||||
for inv_stat in inv_stats:
|
||||
assert_raises_rpc_error(-8, 'Invalid selected statistic %s' % inv_sel_stat,
|
||||
assert_raises_rpc_error(-8, f"Invalid selected statistic '{inv_sel_stat}'",
|
||||
self.nodes[0].getblockstats, hash_or_height=1, stats=inv_stat)
|
||||
|
||||
# Make sure we aren't always returning inv_sel_stat as the culprit stat
|
||||
assert_raises_rpc_error(-8, 'Invalid selected statistic aaa%s' % inv_sel_stat,
|
||||
self.nodes[0].getblockstats, hash_or_height=1, stats=['minfee' , 'aaa%s' % inv_sel_stat])
|
||||
assert_raises_rpc_error(-8, f"Invalid selected statistic 'aaa{inv_sel_stat}'",
|
||||
self.nodes[0].getblockstats, hash_or_height=1, stats=['minfee', f'aaa{inv_sel_stat}'])
|
||||
# Mainchain's genesis block shouldn't be found on regtest
|
||||
assert_raises_rpc_error(-5, 'Block not found', self.nodes[0].getblockstats,
|
||||
hash_or_height='000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f')
|
||||
|
||||
Reference in New Issue
Block a user