mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
4fcd7850b0
8925df86c4df16b1070343fef8e4d238f3cc3bd1 doc: update release notes (Jon Atack) 8bb405bbadf11391ccba7b334b4cfe66dc85b390 test: getaddressinfo labels purpose deprecation test (Jon Atack) 60aba1f2f11529add115d963d05599130288ae28 rpc: simplify getaddressinfo labels, deprecate previous behavior (Jon Atack) 7851f14ccf2bcd1e9b2ad48e5e08881be06d9d21 rpc: incorporate review feedback from PR 17283 (Jon Atack) Pull request description: This PR builds on #17283 (now merged) and is followed by #17585. It modifies the value returned by rpc getaddressinfo `labels` to an array of label name strings and deprecates the previous behavior of returning an array of JSON hash structures containing label `name` and address `purpose` key/value pairs. before ``` "labels": [ { "name": "DOUBLE SPEND", "purpose": "receive" } ``` after ``` "labels": [ "DOUBLE SPEND" ] ``` The deprecated behavior can be re-enabled by starting bitcoind with `-deprecatedrpc=labelspurpose`. For context, see: - https://github.com/bitcoin/bitcoin/pull/17283#issuecomment-554458001 - http://www.erisian.com.au/bitcoin-core-dev/log-2019-12-13.html#l-425 (lines 425-427) - http://www.erisian.com.au/bitcoin-core-dev/log-2019-11-22.html#l-622 Reviewers: This PR may be tested manually by building, then running bitcoind with and without the `-deprecatedrpc=labelspurpose` flag while verifying the rpc getaddressinfo help text and `labels` output. Next steps: deprecate the rpc getaddressinfo `label` field (EDIT: done in #17585) and add support for multiple labels per address. This PR will unblock those. ACKs for top commit: jnewbery: reACK 8925df8 promag: Code review ACK 8925df86c4df16b1070343fef8e4d238f3cc3bd1. meshcollider: Code review ACK 8925df86c4df16b1070343fef8e4d238f3cc3bd1 Tree-SHA512: c2b717209996da32b6484de7bb8800e7048410f9ce6afdb3e02a6866bd4a8f2c730f905fca27b10b877b91cf407f546e69e8c4feb9cd934325a6c71c166bd438
49 lines
2.0 KiB
Python
Executable File
49 lines
2.0 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 hash of `name` and purpose` key-value pairs. It now
|
|
returns an array of label names.
|
|
|
|
"""
|
|
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
|
|
self.setup_clean_chain = False
|
|
# 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()
|