test: Add multiple transactions and error handling tests for getreceivedbyaddress #34188

pull b-l-u-e wants to merge 1 commits into bitcoin:master from b-l-u-e:test-wallet-getreceivedbyaddress changing 1 files +12 −1
  1. b-l-u-e commented at 5:56 am on January 2, 2026: none
    This PR adds comprehensive functional test coverage for the getreceivedbyaddress RPC method.
  2. bensig commented at 8:18 am on January 2, 2026: contributor

    ACK 0d0b34d

    Built with wallet support and ran on macOS - all 4 test scenarios pass.

    Good coverage of minconf behavior, multiple transactions, error handling, and coinbase maturity.

    nit: Copyright header says 2017-2022 but this is a new file - might want to update to 2026-present or similar.

  3. b-l-u-e commented at 8:51 am on January 2, 2026: none

    nit: Copyright header says 2017-2022 but this is a new file - might want to update to 2026-present or similar.

    Aah thank you I will update

  4. DrahtBot commented at 8:51 am on January 2, 2026: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34188.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK rkrux
    Stale ACK bensig

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #30972 (Wallet: “listreceivedby*” fix by BrandonOdiwuor)

    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. maflcko commented at 8:53 am on January 2, 2026: member
    How is this different from test/functional/wallet_listreceivedby.py? Can you explain what exact coverage is missing and what exact coverage is added?
  6. b-l-u-e force-pushed on Jan 2, 2026
  7. b-l-u-e commented at 10:38 am on January 2, 2026: none

    How is this different from test/functional/wallet_listreceivedby.py? Can you explain what exact coverage is missing and what exact coverage is added?

    the test adds two important coverage areas that are missing in wallet_listreceivedby.py

    multiple transactions to the same address , which is a use case not covered in the existing test. The existing test only sends a single transaction (0.1 BTC) to an address.

    invalid address format error - tests error -5 “Invalid Bitcoin address” for malformed address strings. The existing test only covers error -4 “Address not found in wallet” this completes the error handling coverage.

    test file provides better organization and focuses specifically on getreceivedbyaddress , there is some overlap with basic functionality, but the new test adds valuable coverage that was missing.

  8. maflcko commented at 11:28 am on January 2, 2026: member
    My preference would be to keep related functionality checks for related RPCs in the same file, not create a separate file for each RPC. This will also avoid checking the same overlap several times redundantly.
  9. DrahtBot added the label CI failed on Jan 2, 2026
  10. DrahtBot removed the label CI failed on Jan 2, 2026
  11. DrahtBot added the label Tests on Jan 2, 2026
  12. b-l-u-e force-pushed on Jan 2, 2026
  13. b-l-u-e renamed this:
    test: Add functional test for getreceivedbyaddress RPC
    test: Add multiple transactions and error handling tests for getreceivedbyaddress
    on Jan 2, 2026
  14. fanquake commented at 3:12 pm on January 2, 2026: member

    https://github.com/bitcoin/bitcoin/actions/runs/20658978454/job/59322217188?pr=34188#step:6:145:

    0 The subject line of commit hash 1538fc6d86d1d439646ab724ca7a721867213b14 is followed by a non-empty line. Subject lines should always be followed by a blank line.
    
  15. DrahtBot added the label CI failed on Jan 2, 2026
  16. DrahtBot commented at 4:26 pm on January 2, 2026: contributor

    🚧 At least one of the CI tasks failed. Task lint: https://github.com/bitcoin/bitcoin/actions/runs/20658978454/job/59322217188 LLM reason (✨ experimental): Commit message formatting failed lint check (missing blank line after the subject), causing the CI to fail.

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  17. b-l-u-e force-pushed on Jan 2, 2026
  18. in test/functional/wallet_listreceivedby.py:193 in 9944a4c71e
    187@@ -176,7 +188,10 @@ def run_test(self):
    188         label = "label"
    189         address = self.nodes[0].getnewaddress(label)
    190 
    191-        reward = Decimal("25")
    192+        # Calculate expected reward based on block height (50 BTC halved every 150 blocks)
    193+        block_height = self.nodes[0].getblockcount()
    194+        halvings = block_height // 150
    


    fjahr commented at 11:23 pm on January 3, 2026:
    I don’t see much value in this, instead of hardcoding the reward you are hardcoding the halving interval while adding 3 LOC that don’t contribute anything to the actual test.

    b-l-u-e commented at 12:56 pm on January 4, 2026:
    thanks @fjahr. i added the calculation thinking it would make the test more robust but it doesn’t..reverted back
  19. b-l-u-e force-pushed on Jan 4, 2026
  20. b-l-u-e requested review from fjahr on Jan 4, 2026
  21. in test/functional/wallet_listreceivedby.py:131 in 66bd4bf02d
    123@@ -124,6 +124,18 @@ def run_test(self):
    124         # Trying to getreceivedby for an address the wallet doesn't own should return an error
    125         assert_raises_rpc_error(-4, "Address not found in wallet", self.nodes[0].getreceivedbyaddress, addr)
    126 
    127+        # Test multiple transactions to the same address
    128+        addr_multiple = self.nodes[1].getnewaddress()
    129+        self.nodes[0].sendtoaddress(addr_multiple, Decimal("0.1"))
    130+        self.nodes[0].sendtoaddress(addr_multiple, Decimal("0.2"))
    131+        self.sync_all()
    


    rkrux commented at 12:37 pm on January 5, 2026:

    This is not necessary when the blocks are being generated right after.

    0-        self.sync_all()
    
  22. in test/functional/wallet_listreceivedby.py:128 in 66bd4bf02d
    123@@ -124,6 +124,18 @@ def run_test(self):
    124         # Trying to getreceivedby for an address the wallet doesn't own should return an error
    125         assert_raises_rpc_error(-4, "Address not found in wallet", self.nodes[0].getreceivedbyaddress, addr)
    126 
    127+        # Test multiple transactions to the same address
    128+        addr_multiple = self.nodes[1].getnewaddress()
    


    rkrux commented at 12:40 pm on January 5, 2026:

    While it’s easy to understand in this PR, this address name can be confusing for readers when it’s read later. Consider:

     0diff --git a/test/functional/wallet_listreceivedby.py b/test/functional/wallet_listreceivedby.py
     1index 52a503b9d5..8169f9f28c 100755
     2--- a/test/functional/wallet_listreceivedby.py
     3+++ b/test/functional/wallet_listreceivedby.py
     4@@ -125,12 +125,11 @@ class ReceivedByTest(BitcoinTestFramework):
     5         assert_raises_rpc_error(-4, "Address not found in wallet", self.nodes[0].getreceivedbyaddress, addr)
     6 
     7         # Test multiple transactions to the same address
     8-        addr_multiple = self.nodes[1].getnewaddress()
     9-        self.nodes[0].sendtoaddress(addr_multiple, Decimal("0.1"))
    10-        self.nodes[0].sendtoaddress(addr_multiple, Decimal("0.2"))
    11+        addr_with_multiple_txs = self.nodes[1].getnewaddress()
    12+        self.nodes[0].sendtoaddress(addr_with_multiple_txs, Decimal("0.1"))
    13+        self.nodes[0].sendtoaddress(addr_with_multiple_txs, Decimal("0.2"))
    14         self.generate(self.nodes[1], 10)
    15-        balance = self.nodes[1].getreceivedbyaddress(addr_multiple)
    16+        balance = self.nodes[1].getreceivedbyaddress(addr_with_multiple_txs)
    17         assert_equal(balance, Decimal("0.3"))
    18 
    19         # Test invalid address format error
    
  23. in test/functional/wallet_listreceivedby.py:159 in 66bd4bf02d


    rkrux commented at 12:42 pm on January 5, 2026:

    Nit because this PR is not touching this line but there seems to be an incorrect naming here in the comment that can fixed in this PR because it’s related to the same RPC:

    0@@ -156,7 +155,7 @@ class ReceivedByTest(BitcoinTestFramework):
    1                             {"label": label},
    2                             received_by_label_json)
    3 
    4-        # getreceivedbyaddress should return same balance because of 0 confirmations
    5+        # getreceivedbylabel should return same balance because of 0 confirmations
    6         balance = self.nodes[1].getreceivedbylabel(label)
    7         assert_equal(balance, balance_by_label)
    

    rkrux commented at 12:44 pm on January 5, 2026:

    In commit message 66bd4bf02dcfebee9be9846583d11f5b39dc281d because it’s outdated now:

    0- Update coinbase reward calculation to be dynamic
    
  24. rkrux changes_requested
  25. rkrux commented at 12:46 pm on January 5, 2026: contributor

    Concept ACK 66bd4bf02dcfebee9be9846583d11f5b39dc281d

    0https://maflcko.github.io/b-c-cov/total.coverage/src/wallet/rpc/coins.cpp.gcov.html
    

    Although there isn’t increased coverage due to the multiple transactions on same address test but logically it’s good to have such a test. The invalid address test should increase the coverage.

  26. test: Add getreceivedbyaddress coverage to wallet_listreceivedby
    - Add test for multiple transactions to same address
    - Add test for invalid address format error
    0cbef7c3bd
  27. b-l-u-e force-pushed on Jan 5, 2026
  28. b-l-u-e requested review from rkrux on Jan 5, 2026

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-01-07 03:13 UTC

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