forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: getaddressinfo labels purpose deprecation test
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
test/functional/rpc_getaddressinfo_labels_purpose_deprecation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters