test: fix 'unknown named parameter' test in `wallet_basic` #28288

pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2023-08-test-remove-duplicated-assert-wallet-basic changing 1 files +1 −5
  1. brunoerg commented at 7:04 PM on August 17, 2023: contributor

    This PR removes loop when testing an unknown named parameter. They don't have any effect.

  2. DrahtBot commented at 7:04 PM on August 17, 2023: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK theStack, jonatack
    Stale ACK kevkevinpal

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Tests on Aug 17, 2023
  4. brunoerg force-pushed on Aug 17, 2023
  5. DrahtBot added the label CI failed on Aug 17, 2023
  6. kevkevinpal commented at 5:33 AM on August 18, 2023: contributor

    ACK d9ef627

  7. maflcko requested review from jonatack on Aug 18, 2023
  8. DrahtBot removed the label CI failed on Aug 18, 2023
  9. in test/functional/wallet_basic.py:313 in d9ef627af7 outdated
     309 | @@ -310,8 +310,7 @@ def run_test(self):
     310 |          node_0_bal += amount
     311 |          assert_equal(self.nodes[0].getbalance(), node_0_bal)
     312 |  
     313 | -        for key in ["totalFee", "feeRate"]:
     314 | -            assert_raises_rpc_error(-8, "Unknown named parameter key", self.nodes[2].sendtoaddress, address=address, amount=1, fee_rate=1, key=1)
     315 | +        assert_raises_rpc_error(-8, "Unknown named parameter key", self.nodes[2].sendtoaddress, address=address, amount=1, fee_rate=1, key=1)
    


    jonatack commented at 6:44 PM on August 18, 2023:

    Suggestion for both sites.

            assert_raises_rpc_error(-8, "Unknown named parameter feeRate", self.nodes[2].sendtoaddress, address=address, amount=1, fee_rate=1, feeRate=1)
    
  10. jonatack commented at 7:12 PM on August 18, 2023: member

    ACK, good catch. These tests were part of #20305, and I suppose the idea was to ensure totalFee and feeRate kwargs weren't valid. totalFee was then deprecated and subsequently removed from the codebase (there is a similar test in wallet_bumpfee.py). Testing for feeRate might be more interesting than for key.

  11. brunoerg force-pushed on Aug 18, 2023
  12. brunoerg commented at 7:51 PM on August 18, 2023: contributor

    Thanks, @jonatack. Force-pushed changing it to feeRate instead of key.

  13. jonatack commented at 8:09 PM on August 18, 2023: member

    ACK 551c4e036dc18e6b4a917d854c9785170898aff7

  14. theStack commented at 7:37 PM on August 19, 2023: contributor

    Concept ACK

    Could keep the loop and test for both invalid parameters (what was seemingly intended), as also done in e.g. wallet_bumpfee.py? https://github.com/bitcoin/bitcoin/blob/9b066da8af77f971046a42118fd65046321bed1b/test/functional/wallet_bumpfee.py#L126-L127 (I think you'd need the dict unpacking operator ** in this case though, as the parameters before are not positional, see https://stackoverflow.com/questions/47907268/how-do-i-pass-a-string-as-an-argument-name)

    Also, IIUC the second loop could be removed completely, there is no value in having the exact same test executed twice for legacy wallets.

  15. brunoerg force-pushed on Aug 21, 2023
  16. brunoerg commented at 11:36 AM on August 21, 2023: contributor

    Thanks, @theStack for the review. It seems better to keep the loop, just pushed changing it. Also, I checked that for both legacy and descriptor the first occurance is enough, so there is no need to have both. Removed the second one.

  17. theStack approved
  18. theStack commented at 12:05 PM on August 21, 2023: contributor

    ACK 9ad950031bc487a089ada5aeb9d0bef467b74dd3

  19. jonatack commented at 10:27 PM on August 21, 2023: member

    Could keep the loop and test for both invalid parameters (what was seemingly intended), as also done in e.g. wallet_bumpfee.py?

    I'm not sure that's necessary. totalFee was deprecated and then later removed from the codebase completely. It was only ever an argument in RPC bumpfee. I don't recall why I tested for it in this file. It may have been an inadvertent copy-paste as that PR was fairly large and by the time it was done the diff had become a blur.

  20. in test/functional/wallet_basic.py:314 in 9ad950031b outdated
     310 | @@ -311,7 +311,7 @@ def run_test(self):
     311 |          assert_equal(self.nodes[0].getbalance(), node_0_bal)
     312 |  
     313 |          for key in ["totalFee", "feeRate"]:
     314 | -            assert_raises_rpc_error(-8, "Unknown named parameter key", self.nodes[2].sendtoaddress, address=address, amount=1, fee_rate=1, key=1)
     315 | +             assert_raises_rpc_error(-8, f"Unknown named parameter {key}", self.nodes[2].sendtoaddress, address=address, amount=1, fee_rate=1, **{key: 1})
    


    jonatack commented at 10:32 PM on August 21, 2023:

    nit, indentation

                assert_raises_rpc_error(-8, f"Unknown named parameter {key}", self.nodes[2].sendtoaddress, address=address, amount=1, fee_rate=1, **{key: 1})
    
  21. test: fix 'unknown named parameter' test in `wallet_basic`
    Fixes loop when testing an unknown named parameter.
    452c094449
  22. brunoerg force-pushed on Aug 22, 2023
  23. brunoerg commented at 12:16 AM on August 22, 2023: contributor

    I preferred to remove totalFee since it never had any relation to sendtoaddress, left only feeRate. I kept the removal of the second (and redundant) assert.

  24. DrahtBot added the label CI failed on Aug 22, 2023
  25. theStack approved
  26. theStack commented at 1:48 AM on August 22, 2023: contributor

    re-ACK 452c094449de00f3640e6e0763366e7603375825

    (CI fail is in a different functional test and hence unrelated)

  27. jonatack commented at 1:56 AM on August 22, 2023: member

    ACK 452c094449de00f3640e6e0763366e7603375825

    Thanks for fixing my oversights here.

  28. jonatack commented at 2:01 AM on August 22, 2023: member

    (CI fail is in a different functional test and hence unrelated)

    Filed an issue to report it.

  29. DrahtBot removed the label CI failed on Aug 22, 2023
  30. fanquake merged this on Aug 22, 2023
  31. fanquake closed this on Aug 22, 2023

  32. Frank-GER referenced this in commit 159c10f9a5 on Sep 8, 2023
  33. bitcoin locked this on Aug 21, 2024

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-05-02 03:13 UTC

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