2020-07-10 07:28:45 +02:00
|
|
|
#!/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.
|
2020-09-26 17:24:33 +02:00
|
|
|
"""Test deprecation of getpeerinfo RPC fields."""
|
2020-07-10 07:28:45 +02:00
|
|
|
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
|
|
|
|
|
|
|
2020-09-26 17:24:33 +02:00
|
|
|
class GetpeerinfoDeprecationTest(BitcoinTestFramework):
|
2020-07-10 07:28:45 +02:00
|
|
|
def set_test_params(self):
|
|
|
|
self.num_nodes = 2
|
|
|
|
self.extra_args = [[], ["-deprecatedrpc=banscore"]]
|
|
|
|
|
|
|
|
def run_test(self):
|
2020-09-26 17:24:33 +02:00
|
|
|
self.test_banscore_deprecation()
|
|
|
|
self.test_addnode_deprecation()
|
|
|
|
|
|
|
|
def test_banscore_deprecation(self):
|
2020-07-10 07:28:45 +02:00
|
|
|
self.log.info("Test getpeerinfo by default no longer returns a banscore field")
|
|
|
|
assert "banscore" not in self.nodes[0].getpeerinfo()[0].keys()
|
|
|
|
|
|
|
|
self.log.info("Test getpeerinfo returns banscore with -deprecatedrpc=banscore")
|
|
|
|
assert "banscore" in self.nodes[1].getpeerinfo()[0].keys()
|
|
|
|
|
2020-09-26 17:24:33 +02:00
|
|
|
def test_addnode_deprecation(self):
|
|
|
|
self.restart_node(1, ["-deprecatedrpc=getpeerinfo_addnode"])
|
|
|
|
self.connect_nodes(0, 1)
|
|
|
|
|
|
|
|
self.log.info("Test getpeerinfo by default no longer returns an addnode field")
|
|
|
|
assert "addnode" not in self.nodes[0].getpeerinfo()[0].keys()
|
|
|
|
|
|
|
|
self.log.info("Test getpeerinfo returns addnode with -deprecatedrpc=addnode")
|
|
|
|
assert "addnode" in self.nodes[1].getpeerinfo()[0].keys()
|
|
|
|
|
2020-07-10 07:28:45 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-09-26 17:24:33 +02:00
|
|
|
GetpeerinfoDeprecationTest().main()
|