Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115597
D7949.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D7949.diff
View Options
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -20,7 +20,40 @@
wait_until,
)
from test_framework.mininode import P2PInterface
-from test_framework.messages import CAddress, msg_addr, NODE_NETWORK
+from test_framework.messages import (
+ CAddress,
+ msg_addr,
+ NODE_NETWORK,
+ NODE_GETUTXO,
+ NODE_BLOOM,
+ NODE_XTHIN,
+ NODE_BITCOIN_CASH,
+ NODE_NETWORK_LIMITED,
+ NODE_AVALANCHE,
+)
+
+
+def assert_net_servicesnames(servicesflag, servicenames):
+ """Utility that checks if all flags are correctly decoded in
+ `getpeerinfo` and `getnetworkinfo`.
+
+ :param servicesflag: The services as an integer.
+ :param servicesnames: The list of decoded services names, as strings.
+ """
+ if servicesflag & NODE_NETWORK:
+ assert "NETWORK" in servicenames
+ if servicesflag & NODE_GETUTXO:
+ assert "GETUTXO" in servicenames
+ if servicesflag & NODE_BLOOM:
+ assert "BLOOM" in servicenames
+ if servicesflag & NODE_XTHIN:
+ assert "XTHIN" in servicenames
+ if servicesflag & NODE_BITCOIN_CASH:
+ assert "BITCOIN_CASH" in servicenames
+ if servicesflag & NODE_NETWORK_LIMITED:
+ assert "NETWORK_LIMITED" in servicenames
+ if servicesflag & NODE_AVALANCHE:
+ assert "AVALANCHE" in servicenames
class NetTest(BitcoinTestFramework):
@@ -37,7 +70,7 @@
self._test_connection_count()
self._test_getnettotals()
- self._test_getnetworkinginfo()
+ self._test_getnetworkinfo()
self._test_getaddednodeinfo()
self._test_getpeerinfo()
self._test_getnodeaddresses()
@@ -88,7 +121,7 @@
'ping', 0), before['bytessent_per_msg'].get(
'ping', 0) + 32)
- def _test_getnetworkinginfo(self):
+ def _test_getnetworkinfo(self):
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True)
assert_equal(self.nodes[0].getnetworkinfo()['connections'], 2)
@@ -106,6 +139,12 @@
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True)
assert_equal(self.nodes[0].getnetworkinfo()['connections'], 2)
+ # check the `servicesnames` field
+ network_info = [node.getnetworkinfo() for node in self.nodes]
+ for info in network_info:
+ assert_net_servicesnames(
+ int(info["localservices"]), info["localservicesnames"])
+
def _test_getaddednodeinfo(self):
assert_equal(self.nodes[0].getaddednodeinfo(), [])
# add a node (node2) to node0
@@ -128,6 +167,10 @@
assert_equal(peer_info[1][0]['addrbind'], peer_info[0][0]['addr'])
assert_equal(peer_info[0][0]['minfeefilter'], Decimal("0.00000500"))
assert_equal(peer_info[1][0]['minfeefilter'], Decimal("0.00001000"))
+ # check the `servicesnames` field
+ for info in peer_info:
+ assert_net_servicesnames(
+ int(info[0]["services"]), info[0]["servicesnames"])
def _test_getnodeaddresses(self):
self.nodes[0].add_p2p_connection(P2PInterface())
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
--- a/test/functional/test_framework/messages.py
+++ b/test/functional/test_framework/messages.py
@@ -47,7 +47,7 @@
COIN = 100000000
NODE_NETWORK = (1 << 0)
-# NODE_GETUTXO = (1 << 1)
+NODE_GETUTXO = (1 << 1)
NODE_BLOOM = (1 << 2)
# NODE_WITNESS = (1 << 3)
NODE_XTHIN = (1 << 4)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:30 (4 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187617
Default Alt Text
D7949.diff (3 KB)
Attached To
D7949: tests: add a test for the 'servicesnames' RPC field
Event Timeline
Log In to Comment