/tx
(rest) passing an invalid and an unknown txid to test its return.
Invalid -> should return status code 400 (bad request)
Unknown -> should return status code 404 (not found)
test: rest /tx with an invalid/unknown txid #24054
pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2022-01-rest-functional changing 1 files +14 −4-
brunoerg commented at 11:00 am on January 13, 2022: memberThis PR adds test coverage to the endpoint
-
fanquake added the label Tests on Jan 13, 2022
-
brunoerg force-pushed on Jan 13, 2022
-
jonatack commented at 6:49 pm on January 13, 2022: member
ACK a6376a823d9862342d9f3542349e81912c4bdb69
A couple of (more self-documenting?) ideas for fun, feel free to ignore.
0 invalid_txid = "abc" 1 resp = self.test_rest_request(uri=f"/tx/{invalid_txid}", ret_type=RetType.OBJ, status=400) 2 assert_equal(resp.read().decode('utf-8').rstrip(), f"Invalid hash: {invalid_txid}") 3 4 unknown_txid ="0000000000000000000000000000000000000000000000000000000000000000" 5 resp = self.test_rest_request(uri=f"/tx/{unknown_txid}", ret_type=RetType.OBJ, status=404) 6 assert_equal(resp.read().decode('utf-8').rstrip(), f"{unknown_txid} not found")
0 invalid_txid = "abc" 1 unknown_txid = "0000000000000000000000000000000000000000000000000000000000000000" 2 for tx in [{'id': invalid_txid, 'status': 400, 'error': f"Invalid hash: {invalid_txid}"}, 3 {'id': unknown_txid, 'status': 404, 'error': f"{unknown_txid} not found"}]: 4 resp = self.test_rest_request(uri=f"/tx/{tx['id']}", status=tx['status'], ret_type=RetType.OBJ) 5 assert_equal(resp.read().decode('utf-8').rstrip(), tx['error'])
-
brunoerg force-pushed on Jan 13, 2022
-
test: rest /tx with an invalid/unknown txid bd52684508
-
in test/functional/interface_rest.py:108 in 6e3caa9a53 outdated
102@@ -103,6 +103,14 @@ def run_test(self): 103 n, = filter_output_indices_by_value(json_obj['vout'], Decimal('0.1')) 104 spending = (txid, n) 105 106+ # Test /tx with an invalid and an unknown txid 107+ invalid_param = "abc" 108+ unknown_param = "0000000000000000000000000000000000000000000000000000000000000000"
jonatack commented at 7:50 pm on January 13, 2022:Ah, nice that these can be reused. Since the reuses are much further down, maybe hoist these to constants at the top.
brunoerg commented at 8:02 pm on January 13, 2022:Cool! Done!brunoerg force-pushed on Jan 13, 2022DrahtBot commented at 2:32 am on January 14, 2022: memberThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #24098 (rest: Use query parameters to control resource loading by stickies-v)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
kallewoof commented at 7:34 am on January 19, 2022: memberACK bd52684508ca2964e6a3af503d21ff99675380c7MarcoFalke merged this on Jan 19, 2022MarcoFalke closed this on Jan 19, 2022
jonatack commented at 5:07 pm on January 19, 2022: memberPosthumous ACKsidhujag referenced this in commit ef54306288 on Jan 20, 2022DrahtBot locked this on Jan 19, 2023
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 15:12 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 15:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me