0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-05 14:06:27 -05:00

rpc: Remove special case for unknown service flags

This commit is contained in:
MarcoFalke 2020-05-29 18:05:40 -04:00
parent cb88de3e3d
commit fa1433ac1b
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
2 changed files with 11 additions and 6 deletions

View file

@ -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>
@ -216,11 +216,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();
}

View file

@ -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()