test: check for invalid listtransactions RPC parameters #23835

pull theStack wants to merge 1 commits into bitcoin:master from theStack:202112-test-rpc-check_invalid_listtransactions_parameters changing 1 files +9 −0
  1. DrahtBot added the label Tests on Dec 21, 2021
  2. in test/functional/wallet_listtransactions.py:282 in 5934b61d5b outdated
     276 | @@ -275,6 +277,13 @@ def normalize_list(txs):
     277 |          assert_equal(['pizza2'], self.nodes[0].getaddressinfo(addr2)['labels'])
     278 |          assert_equal(['pizza3'], self.nodes[0].getaddressinfo(addr3)['labels'])
     279 |  
     280 | +    def run_invalid_parameters_test(self):
     281 | +        self.log.info("Test listtransactions RPC parameter validity")
     282 | +        assert_raises_rpc_error(-8, 'Label argument must be a valid label name or "*"', self.nodes[0].listtransactions, label="")
    


    shaavan commented at 10:16 AM on December 22, 2021:

    nit:

            assert_raises_rpc_error(-8, 'Label argument must be a valid label name or "*".', self.nodes[0].listtransactions, label="")
    

    theStack commented at 7:46 PM on December 22, 2021:

    Thanks, fixed!

  3. shaavan commented at 10:16 AM on December 22, 2021: contributor

    Concept ACK

    The added test looks suitable for the code given in the description. The lines are tested in the following way:

    • Line 508: By giving "" as the label.
    • Line 524: By giving -1 as count.
    • Line 526: By giving -1 skip value.

    The code given for RPC_INVALID_PARAMETER is also correct ( = -8).

    However, there's one minor nit I caught.

  4. test: check for invalid listtransactions RPC parameters c27bba9672
  5. in test/functional/wallet_listtransactions.py:283 in 5934b61d5b outdated
     276 | @@ -275,6 +277,13 @@ def normalize_list(txs):
     277 |          assert_equal(['pizza2'], self.nodes[0].getaddressinfo(addr2)['labels'])
     278 |          assert_equal(['pizza3'], self.nodes[0].getaddressinfo(addr3)['labels'])
     279 |  
     280 | +    def run_invalid_parameters_test(self):
     281 | +        self.log.info("Test listtransactions RPC parameter validity")
     282 | +        assert_raises_rpc_error(-8, 'Label argument must be a valid label name or "*"', self.nodes[0].listtransactions, label="")
     283 | +        self.nodes[0].listtransactions(label="*")
    


    brunoerg commented at 10:44 AM on December 22, 2021:

    I didn't understand this line, I think you're not using the return of this listtransactions. Noticed that removing it, the test doesn't fail.


    theStack commented at 7:45 PM on December 22, 2021:

    The intention here is to ensure that passing "*" as label is considered valid; the asterisk is not passed in any other part of the tests, so I thought it would make sense to do it here. I agree though that it looks a bit odd.

  6. theStack force-pushed on Dec 22, 2021
  7. shaavan approved
  8. shaavan commented at 10:33 AM on December 23, 2021: contributor

    ACK c27bba96723384488fb6995e21bb43969d94b0f6

    Change since my last review:

    • Addressed suggestion under this comment
  9. MarcoFalke merged this on Dec 24, 2021
  10. MarcoFalke closed this on Dec 24, 2021

  11. theStack deleted the branch on Dec 24, 2021
  12. sidhujag referenced this in commit 373589c42f on Dec 27, 2021
  13. DrahtBot locked this on Dec 24, 2022
Labels

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: 2026-04-14 21:13 UTC

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