Add regtests for HTTP status codes #15495

pull domob1812 wants to merge 1 commits into bitcoin:master from domob1812:test-http-code changing 2 files +36 −9
  1. domob1812 commented at 2:49 pm on February 27, 2019: contributor

    This adds explicit tests for the returned HTTP status codes to interface_rpc.py (for error cases) and the HTTP JSON-RPC client in general for success.

    #15381 brought up discussion about the HTTP status codes in general, and the general opinion was that the current choice may not be ideal but should not be changed to preserve compatibility with existing JSON-RPC clients. Thus it makes sense to actually test the current status to ensure this desired compatibility is not broken accidentally.

  2. fanquake added the label Tests on Feb 27, 2019
  3. domob1812 renamed this:
    Add regtests for HTTP status codes.
    Add regtests for HTTP status codes
    on Feb 27, 2019
  4. DrahtBot commented at 4:35 pm on February 27, 2019: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #15483 (rpc: Adding a ’logpath’ entry to getrpcinfo by darosior)
    • #15381 (Optionally return HTTP_OK for RPC errors by domob1812)

    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.

  5. Add regtests for HTTP status codes.
    This adds explicit tests for the returned HTTP status codes to
    interface_rpc.py (for error cases) and the HTTP JSON-RPC client in
    general for success.
    
    PR 15381 brought up discussion about the HTTP status codes in general,
    and the general opinion was that the current choice may not be ideal
    but should not be changed to preserve compatibility with existing
    JSON-RPC clients.  Thus it makes sense to actually test the current
    status to ensure this desired compatibility is not broken accidentally.
    8f5d9431a3
  6. in test/functional/test_framework/authproxy.py:143 in 9e49c8bed0 outdated
    141         elif 'result' not in response:
    142             raise JSONRPCException({
    143-                'code': -343, 'message': 'missing JSON-RPC result'})
    144+                'code': -343, 'message': 'missing JSON-RPC result'}, status)
    145+        elif status != HTTPStatus.OK:
    146+            raise JSONRPCExceptoin({
    


    practicalswift commented at 8:22 pm on February 28, 2019:
    JSONRPCExceptoin does not exist :-)

    domob1812 commented at 7:27 am on March 1, 2019:

    So we are testing that this unexpected situation does not occur by means of Python throwing an error otherwise. :)

    Good catch, fixed!

  7. domob1812 force-pushed on Mar 1, 2019
  8. practicalswift commented at 7:33 am on March 1, 2019: contributor
    Concept ACK
  9. in test/functional/interface_rpc.py:11 in 8f5d9431a3
     7 
     8+from test_framework.authproxy import JSONRPCException
     9 from test_framework.test_framework import BitcoinTestFramework
    10 from test_framework.util import assert_equal, assert_greater_than_or_equal
    11 
    12+def expect_http_status(expected_http_status, expected_rpc_code,
    


    promag commented at 8:50 pm on March 3, 2019:
    You could move this to test/functional/test_framework/util.py or even try to extend assert_raises_rpc_error?

    domob1812 commented at 7:09 am on March 4, 2019:

    I’m not sure if that makes sense - checking the HTTP status code is a rather specific thing, which I don’t expect us to do outside of this one test. Thus I think it makes sense to keep the code here.

    But if you disagree and see us checking status codes in other tests as well, I’m happy to move this to a more general place.


    promag commented at 8:44 am on March 4, 2019:
    Ok, it can be moved if needed.

    domob1812 commented at 3:56 pm on March 4, 2019:
    Yeah, that’s what I think is best. (But if anyone else feels like we should have this general right away, let me know and I will extend assert_raises_rpc_error to optionally check the HTTP status.)
  10. promag commented at 8:51 pm on March 3, 2019: member
    Concept ACK.
  11. laanwj commented at 6:28 pm on March 7, 2019: member
    utACK 8f5d9431a36740aa12abc0acea64df48fe32d2a6
  12. promag commented at 11:39 pm on March 17, 2019: member
    utACK 8f5d943.
  13. domob1812 commented at 6:09 am on April 8, 2019: contributor
    Is this good to merge, or is anything left for me to do?
  14. jonasschnelli commented at 7:06 am on April 8, 2019: contributor
    utACK 8f5d9431a36740aa12abc0acea64df48fe32d2a6
  15. jonasschnelli merged this on Apr 8, 2019
  16. jonasschnelli closed this on Apr 8, 2019

  17. jonasschnelli referenced this in commit 327d2746fb on Apr 8, 2019
  18. domob1812 deleted the branch on Apr 8, 2019
  19. jasonbcox referenced this in commit 4c94f3fa8c on Oct 5, 2020
  20. PastaPastaPasta referenced this in commit 9d7529e235 on Sep 11, 2021
  21. PastaPastaPasta referenced this in commit 7b451c4843 on Sep 11, 2021
  22. PastaPastaPasta referenced this in commit fc66b3f505 on Sep 12, 2021
  23. DrahtBot locked this on Dec 16, 2021

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-21 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me