aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2022-05-12 16:51:36 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2022-05-20 16:32:09 -0300
commit8897a21658ad93f7b628eb2a3411fec2265d73fb (patch)
tree7cb9f12ecc615b60174e2d6531d75004e764ecea /test
parent1ab389b1bac1378e17b13a4c4a81c24b92745cfb (diff)
downloadbitcoin-8897a21658ad93f7b628eb2a3411fec2265d73fb.tar.xz
rpc: getreceivedbylabel, don't loop over the entire wallet txs map if no destinations were found for the input label.
If wallet.GetLabelAddresses() returns an empty vector (the wallet does not have addresses with that label in the addressbook) or if none of the returned destinations are from the wallet, we can return the function right away.
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/wallet_listreceivedby.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/functional/wallet_listreceivedby.py b/test/functional/wallet_listreceivedby.py
index a7f4f9ffaf..7e473bc52c 100755
--- a/test/functional/wallet_listreceivedby.py
+++ b/test/functional/wallet_listreceivedby.py
@@ -131,6 +131,9 @@ class ReceivedByTest(BitcoinTestFramework):
txid = self.nodes[0].sendtoaddress(addr, 0.1)
self.sync_all()
+ # getreceivedbylabel returns an error if the wallet doesn't own the label
+ assert_raises_rpc_error(-4, "Label not found in wallet", self.nodes[0].getreceivedbylabel, "dummy")
+
# listreceivedbylabel should return received_by_label_json because of 0 confirmations
assert_array_result(self.nodes[1].listreceivedbylabel(),
{"label": label},