dash/test/functional/rpc_getaddressinfo_labels_purpose_deprecation.py
MarcoFalke 00d2d7fac3 Merge #21042: doc, test: Improve setup_clean_chain documentation
590bda79e876d9b959083105b8c7c41dd87706eb scripted-diff: Remove setup_clean_chain if default is not changed (Fabian Jahr)
98892f39e3d079c73bff7f2a5d5420fa95270497 doc: Improve setup_clean_chain documentation (Fabian Jahr)

Pull request description:

  The first commit improves documentation on setup_clean_chain which is misunderstood quite frequently. Most importantly it fixes the TestShell docs which are simply incorrect.

  The second commit removes the instances of `setup_clean_clain` in functional tests where it is not changing the default.

  This used to be part of #19168 which also sought to rename`setup_clean_chain`.

ACKs for top commit:
  jonatack:
    ACK 590bda79e876d9b959083105b8c7c41dd87706eb

Tree-SHA512: a7881186e65d31160b8f84107fb185973b37c6e50f190a85c6e2906a13a7472bb4efa9440bd37fe0a9ac5cd2d1e8559870a7e4380632d9a249eca8980b945f3e
2023-08-28 11:31:55 -05:00

48 lines
1.9 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright (c) 2020 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""
Test deprecation of RPC getaddressinfo `labels` returning an array
containing a JSON object of `name` and purpose` key-value pairs. It now
returns an array containing only the label name.
"""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
LABELS_TO_TEST = frozenset({"" , "New 𝅘𝅥𝅯 $<#>&!рыба Label"})
class GetAddressInfoLabelsPurposeDeprecationTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
# Start node[0] with -deprecatedrpc=labelspurpose and node[1] without.
self.extra_args = [["-deprecatedrpc=labelspurpose"], []]
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def test_labels(self, node_num, label_name, expected_value):
node = self.nodes[node_num]
address = node.getnewaddress()
if label_name != "":
node.setlabel(address, label_name)
self.log.info(" set label to {}".format(label_name))
labels = node.getaddressinfo(address)["labels"]
self.log.info(" labels = {}".format(labels))
assert_equal(labels, expected_value)
def run_test(self):
"""Test getaddressinfo labels with and without -deprecatedrpc flag."""
self.log.info("Test getaddressinfo labels with -deprecatedrpc flag")
for label in LABELS_TO_TEST:
self.test_labels(node_num=0, label_name=label, expected_value=[{"name": label, "purpose": "receive"}])
self.log.info("Test getaddressinfo labels without -deprecatedrpc flag")
for label in LABELS_TO_TEST:
self.test_labels(node_num=1, label_name=label, expected_value=[label])
if __name__ == '__main__':
GetAddressInfoLabelsPurposeDeprecationTest().main()