Skip to content

Commit 9b42d62

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25045: test: add coverage for invalid requests for blockfilterheaders (REST)
d1bfe5e test: add coverage for invalid requests for `blockfilterheaders` (brunoerg) Pull request description: This PR adds test coverage for invalid requests (`Invalid hash` and `Unknown filtertype`) for `/blockfilterheaders` in REST functional test. ACKs for top commit: jonatack: ACK d1bfe5e vincenzopalazzo: ACK bitcoin/bitcoin@d1bfe5e Tree-SHA512: 9ab7efe7131296577c60642f95921799cf1dbae9c2aaea6752d2ac9f35a1bcc72b9d742a146c314f82fe1848190a80c88836ab78fc28773ed12e97fa327828e7
2 parents 880cec9 + d1bfe5e commit 9b42d62

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/functional/interface_rest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def run_test(self):
219219

220220
self.generate(self.nodes[0], 1) # generate block to not affect upcoming tests
221221

222-
self.log.info("Test the /block, /blockhashbyheight and /headers URIs")
222+
self.log.info("Test the /block, /blockhashbyheight, /headers, and /blockfilterheaders URIs")
223223
bb_hash = self.nodes[0].getbestblockhash()
224224

225225
# Check result if block does not exists
@@ -300,6 +300,12 @@ def run_test(self):
300300
assert_equal(first_filter_header, rpc_blockfilter['header'])
301301
assert_equal(json_obj['filter'], rpc_blockfilter['filter'])
302302

303+
# Test blockfilterheaders with an invalid hash and filtertype
304+
resp = self.test_rest_request(f"/blockfilterheaders/{INVALID_PARAM}/{bb_hash}", ret_type=RetType.OBJ, status=400)
305+
assert_equal(resp.read().decode('utf-8').rstrip(), f"Unknown filtertype {INVALID_PARAM}")
306+
resp = self.test_rest_request(f"/blockfilterheaders/basic/{INVALID_PARAM}", ret_type=RetType.OBJ, status=400)
307+
assert_equal(resp.read().decode('utf-8').rstrip(), f"Invalid hash: {INVALID_PARAM}")
308+
303309
# Test number parsing
304310
for num in ['5a', '-5', '0', '2001', '99999999999999999999999999999999999']:
305311
assert_equal(

0 commit comments

Comments
 (0)