aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-09-26 17:24:33 +0200
committerMarcoFalke <falke.marco@gmail.com>2020-09-26 17:24:54 +0200
commit4f45ea1f739349d75ef4273bfb369395eec2fb39 (patch)
tree307362991bb029f74807e13110cedc3e315f167c /test
parent8aa3a4a498742dc42631956ed3599b3fb2b80302 (diff)
parenta512925e19a70d7f6b80ac530a169f45ffaafa1c (diff)
downloadbitcoin-4f45ea1f739349d75ef4273bfb369395eec2fb39.tar.xz
Merge #19725: [RPC] Add connection type to getpeerinfo, improve logs
a512925e19a70d7f6b80ac530a169f45ffaafa1c [doc] Release notes (Amiti Uttarwar) 50f94b34a33c954f6e207f509c93d33267a5c3e2 [rpc] Deprecate getpeerinfo addnode field (Amiti Uttarwar) df091b9b509f0b10e4315c0bfa2da0cc0c31c22f [refactor] Rename test file to allow any getpeerinfo deprecations. (Amiti Uttarwar) 395acfa83a5436790c1a722a5609ac9d48df235f [rpc] Add connection type to getpeerinfo RPC, update tests (Amiti Uttarwar) 49c10a9ca40967d28ae16dfea9cccc6f3a6624a1 [log] Add connection type to log statement (Amiti Uttarwar) Pull request description: After #19316, we can more directly expose information about the connection type on the `getpeerinfo` RPC. Doing so also makes the existing addnode field redundant, so this PR begins the process of deprecating this field. This PR also includes one commit that improves a log message, as both use a shared function to return the connection type as a string. Suggested by sdaftuar- https://github.com/bitcoin/bitcoin/pull/19316#discussion_r468001604 & https://github.com/bitcoin/bitcoin/pull/19316#discussion_r468018093 ACKs for top commit: jnewbery: Code review ACK a512925e19a70d7f6b80ac530a169f45ffaafa1c. sipa: utACK a512925e19a70d7f6b80ac530a169f45ffaafa1c guggero: Tested and code review ACK a512925e. MarcoFalke: cr ACK a512925e19a70d7f6b80ac530a169f45ffaafa1c 🌇 promag: Code review ACK a512925e19a70d7f6b80ac530a169f45ffaafa1c. Tree-SHA512: 601a7a38aee235ee59aca690784f886dc2ae4e418b2e6422c4b58cd597376c00f74910f66920b08a08a0bec28bf8022e71a1435785ff6ba8a188954261aba78e
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/rpc_getpeerinfo_banscore_deprecation.py24
-rwxr-xr-xtest/functional/rpc_getpeerinfo_deprecation.py39
-rwxr-xr-xtest/functional/rpc_net.py6
-rwxr-xr-xtest/functional/test_runner.py2
4 files changed, 46 insertions, 25 deletions
diff --git a/test/functional/rpc_getpeerinfo_banscore_deprecation.py b/test/functional/rpc_getpeerinfo_banscore_deprecation.py
deleted file mode 100755
index b830248e1e..0000000000
--- a/test/functional/rpc_getpeerinfo_banscore_deprecation.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/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 getpeerinfo RPC banscore field."""
-
-from test_framework.test_framework import BitcoinTestFramework
-
-
-class GetpeerinfoBanscoreDeprecationTest(BitcoinTestFramework):
- def set_test_params(self):
- self.num_nodes = 2
- self.extra_args = [[], ["-deprecatedrpc=banscore"]]
-
- def run_test(self):
- 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()
-
-
-if __name__ == "__main__":
- GetpeerinfoBanscoreDeprecationTest().main()
diff --git a/test/functional/rpc_getpeerinfo_deprecation.py b/test/functional/rpc_getpeerinfo_deprecation.py
new file mode 100755
index 0000000000..287c40ae3e
--- /dev/null
+++ b/test/functional/rpc_getpeerinfo_deprecation.py
@@ -0,0 +1,39 @@
+#!/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 getpeerinfo RPC fields."""
+
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import connect_nodes
+
+
+class GetpeerinfoDeprecationTest(BitcoinTestFramework):
+ def set_test_params(self):
+ self.num_nodes = 2
+ self.extra_args = [[], ["-deprecatedrpc=banscore"]]
+
+ def run_test(self):
+ self.test_banscore_deprecation()
+ self.test_addnode_deprecation()
+
+ def test_banscore_deprecation(self):
+ 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()
+
+ def test_addnode_deprecation(self):
+ self.restart_node(1, ["-deprecatedrpc=getpeerinfo_addnode"])
+ connect_nodes(self.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()
+
+
+if __name__ == "__main__":
+ GetpeerinfoDeprecationTest().main()
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index bc0e5b458e..b8a04f494d 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -175,6 +175,12 @@ class NetTest(BitcoinTestFramework):
for info in peer_info:
assert_net_servicesnames(int(info[0]["services"], 0x10), info[0]["servicesnames"])
+ assert_equal(peer_info[0][0]['connection_type'], 'inbound')
+ assert_equal(peer_info[0][1]['connection_type'], 'manual')
+
+ assert_equal(peer_info[1][0]['connection_type'], 'manual')
+ assert_equal(peer_info[1][1]['connection_type'], 'inbound')
+
def test_service_flags(self):
self.log.info("Test service flags")
self.nodes[0].add_p2p_connection(P2PInterface(), services=(1 << 4) | (1 << 63))
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index 6c3d50df93..c8cf173d5f 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -251,7 +251,7 @@ BASE_SCRIPTS = [
'feature_config_args.py',
'feature_settings.py',
'rpc_getdescriptorinfo.py',
- 'rpc_getpeerinfo_banscore_deprecation.py',
+ 'rpc_getpeerinfo_deprecation.py',
'rpc_help.py',
'feature_help.py',
'feature_shutdown.py',