|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# Copyright (c) 2020 The Bitcoin Core developers |
| 3 | +# Distributed under the MIT software license, see the accompanying |
| 4 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php. |
| 5 | +""" |
| 6 | +Test deprecation of the RPC getaddressinfo `label` field. It has been |
| 7 | +superceded by the `labels` field. |
| 8 | +
|
| 9 | +""" |
| 10 | +from test_framework.test_framework import BitcoinTestFramework |
| 11 | + |
| 12 | +class GetAddressInfoLabelDeprecationTest(BitcoinTestFramework): |
| 13 | + def set_test_params(self): |
| 14 | + self.num_nodes = 2 |
| 15 | + self.setup_clean_chain = False |
| 16 | + # Start node[0] with -deprecatedrpc=label, and node[1] without. |
| 17 | + self.extra_args = [["-deprecatedrpc=label"], []] |
| 18 | + |
| 19 | + def skip_test_if_missing_module(self): |
| 20 | + self.skip_if_no_wallet() |
| 21 | + |
| 22 | + def test_label_with_deprecatedrpc_flag(self): |
| 23 | + self.log.info("Test getaddressinfo label with -deprecatedrpc flag") |
| 24 | + node = self.nodes[0] |
| 25 | + address = node.getnewaddress() |
| 26 | + info = node.getaddressinfo(address) |
| 27 | + assert "label" in info |
| 28 | + |
| 29 | + def test_label_without_deprecatedrpc_flag(self): |
| 30 | + self.log.info("Test getaddressinfo label without -deprecatedrpc flag") |
| 31 | + node = self.nodes[1] |
| 32 | + address = node.getnewaddress() |
| 33 | + info = node.getaddressinfo(address) |
| 34 | + assert "label" not in info |
| 35 | + |
| 36 | + def run_test(self): |
| 37 | + """Test getaddressinfo label with and without -deprecatedrpc flag.""" |
| 38 | + self.test_label_with_deprecatedrpc_flag() |
| 39 | + self.test_label_without_deprecatedrpc_flag() |
| 40 | + |
| 41 | + |
| 42 | +if __name__ == '__main__': |
| 43 | + GetAddressInfoLabelDeprecationTest().main() |
0 commit comments