mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Merge #19112: rpc: Remove special case for unknown service flags
fa1433ac1b
rpc: Remove special case for unknown service flags (MarcoFalke) Pull request description: The special case to return a bit as an integer is clumsy and undocumented. Probably also irrelevant because there shouldn't currently be a non-misbehaving client that connects to Bitcoin Core and advertises an unknown service flag. Thus, simply remove the code. ACKs for top commit: laanwj: ACKfa1433ac1b
Tree-SHA512: 942de6a577a9ee076ce12c92be121617640d53ee8c3424064c45a30a7ff789555d3722a4203670768faf81da2a40adfed3ec5cdeb5da06f04be81ddb53b9db7e
This commit is contained in:
commit
365f1082e1
2 changed files with 11 additions and 6 deletions
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include <protocol.h>
|
||||
|
||||
#include <util/system.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
|
||||
#ifndef WIN32
|
||||
# include <arpa/inet.h>
|
||||
|
@ -220,11 +220,7 @@ static std::string serviceFlagToStr(size_t bit)
|
|||
std::ostringstream stream;
|
||||
stream.imbue(std::locale::classic());
|
||||
stream << "UNKNOWN[";
|
||||
if (bit < 8) {
|
||||
stream << service_flag;
|
||||
} else {
|
||||
stream << "2^" << bit;
|
||||
}
|
||||
stream << "2^" << bit;
|
||||
stream << "]";
|
||||
return stream.str();
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ from test_framework.messages import (
|
|||
NODE_WITNESS,
|
||||
)
|
||||
|
||||
|
||||
def assert_net_servicesnames(servicesflag, servicenames):
|
||||
"""Utility that checks if all flags are correctly decoded in
|
||||
`getpeerinfo` and `getnetworkinfo`.
|
||||
|
@ -40,6 +41,7 @@ def assert_net_servicesnames(servicesflag, servicenames):
|
|||
servicesflag_generated |= getattr(test_framework.messages, 'NODE_' + servicename)
|
||||
assert servicesflag_generated == servicesflag
|
||||
|
||||
|
||||
class NetTest(BitcoinTestFramework):
|
||||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
|
@ -57,6 +59,7 @@ class NetTest(BitcoinTestFramework):
|
|||
self._test_getnetworkinfo()
|
||||
self._test_getaddednodeinfo()
|
||||
self._test_getpeerinfo()
|
||||
self.test_service_flags()
|
||||
self._test_getnodeaddresses()
|
||||
|
||||
def _test_connection_count(self):
|
||||
|
@ -139,6 +142,11 @@ class NetTest(BitcoinTestFramework):
|
|||
for info in peer_info:
|
||||
assert_net_servicesnames(int(info[0]["services"], 0x10), info[0]["servicesnames"])
|
||||
|
||||
def test_service_flags(self):
|
||||
self.nodes[0].add_p2p_connection(P2PInterface(), services=(1 << 4) | (1 << 63))
|
||||
assert_equal(['UNKNOWN[2^4]', 'UNKNOWN[2^63]'], self.nodes[0].getpeerinfo()[-1]['servicesnames'])
|
||||
self.nodes[0].disconnect_p2ps()
|
||||
|
||||
def _test_getnodeaddresses(self):
|
||||
self.nodes[0].add_p2p_connection(P2PInterface())
|
||||
|
||||
|
@ -174,5 +182,6 @@ class NetTest(BitcoinTestFramework):
|
|||
node_addresses = self.nodes[0].getnodeaddresses(LARGE_REQUEST_COUNT)
|
||||
assert_greater_than(LARGE_REQUEST_COUNT, len(node_addresses))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
NetTest().main()
|
||||
|
|
Loading…
Add table
Reference in a new issue