Merge bitcoin/bitcoin#26730: test: add coverage for purpose arg in listlabels

c467cfffcebb30f829eeb8160166a6b941d97ed6 test: add coverage for `purpose` arg in `listlabels` (brunoerg)

Pull request description:

  This PR adds test coverage for `listlabels` command when specifying the `purpose` (send and receive).

  dcdfd72861/src/wallet/rpc/addresses.cpp (L698-L704)

ACKs for top commit:
  kristapsk:
    ACK c467cfffcebb30f829eeb8160166a6b941d97ed6

Tree-SHA512: 7e7143c1264692f7b22952e7c70dbe9ed3f5dcd2e3b69962a47be9f9c21b3f4a9089ca87962fbc8ff9116e7d2dbeb7f36d6a132c9ac13724a255cfe1b32373a8
This commit is contained in:
MarcoFalke 2023-01-11 14:55:33 +01:00 committed by pasta
parent 6fe46fc02a
commit 07f4c39c44
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -20,7 +20,7 @@ from test_framework.wallet_util import test_address
class WalletLabelsTest(BitcoinTestFramework): class WalletLabelsTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.setup_clean_chain = True self.setup_clean_chain = True
self.num_nodes = 1 self.num_nodes = 2
def skip_test_if_missing_module(self): def skip_test_if_missing_module(self):
self.skip_if_no_wallet() self.skip_if_no_wallet()
@ -82,8 +82,14 @@ class WalletLabelsTest(BitcoinTestFramework):
label.add_receive_address(address) label.add_receive_address(address)
label.verify(node) label.verify(node)
# Check listlabels when passing 'purpose'
node2_addr = self.nodes[1].getnewaddress()
node.setlabel(node2_addr, "node2_addr")
assert_equal(node.listlabels(purpose="send"), ["node2_addr"])
assert_equal(node.listlabels(purpose="receive"), sorted(['coinbase'] + [label.name for label in labels]))
# Check all labels are returned by listlabels. # Check all labels are returned by listlabels.
assert_equal(node.listlabels(), sorted(['coinbase'] + [label.name for label in labels])) assert_equal(node.listlabels(), sorted(['coinbase'] + [label.name for label in labels] + ["node2_addr"]))
# Send a transaction to each label. # Send a transaction to each label.
for label in labels: for label in labels: