20
20
wait_until ,
21
21
)
22
22
from test_framework .mininode import P2PInterface
23
- from test_framework .messages import CAddress , msg_addr , NODE_NETWORK , NODE_WITNESS
23
+ from test_framework .messages import (
24
+ CAddress ,
25
+ msg_addr ,
26
+ NODE_NETWORK ,
27
+ NODE_WITNESS ,
28
+ NODE_GETUTXO ,NODE_BLOOM ,
29
+ NODE_NETWORK_LIMITED ,
30
+ )
31
+
32
+ def assert_net_servicesnames (servicesflag , servicenames ):
33
+ """Utility that checks if all flags are correctly decoded in
34
+ `getpeerinfo` and `getnetworkinfo`.
35
+
36
+ :param servicesflag: The services as an integer.
37
+ :param servicesnames: The list of decoded services names, as strings.
38
+ """
39
+ if servicesflag & NODE_NETWORK :
40
+ assert "NETWORK" in servicenames
41
+ if servicesflag & NODE_GETUTXO :
42
+ assert "GETUTXO" in servicenames
43
+ if servicesflag & NODE_BLOOM :
44
+ assert "BLOOM" in servicenames
45
+ if servicesflag & NODE_WITNESS :
46
+ assert "WITNESS" in servicenames
47
+ if servicesflag & NODE_NETWORK_LIMITED :
48
+ assert "NETWORK_LIMITED" in servicenames
24
49
25
50
class NetTest (BitcoinTestFramework ):
26
51
def set_test_params (self ):
@@ -84,6 +109,11 @@ def _test_getnetworkinginfo(self):
84
109
assert_equal (self .nodes [0 ].getnetworkinfo ()['networkactive' ], True )
85
110
assert_equal (self .nodes [0 ].getnetworkinfo ()['connections' ], 2 )
86
111
112
+ # check the `servicesnames` field
113
+ network_info = [node .getnetworkinfo () for node in self .nodes ]
114
+ for info in network_info :
115
+ assert_net_servicesnames (int (info ["localservices" ]), info ["localservicesnames" ])
116
+
87
117
def _test_getaddednodeinfo (self ):
88
118
assert_equal (self .nodes [0 ].getaddednodeinfo (), [])
89
119
# add a node (node2) to node0
@@ -104,6 +134,9 @@ def _test_getpeerinfo(self):
104
134
assert_equal (peer_info [1 ][0 ]['addrbind' ], peer_info [0 ][0 ]['addr' ])
105
135
assert_equal (peer_info [0 ][0 ]['minfeefilter' ], Decimal ("0.00000500" ))
106
136
assert_equal (peer_info [1 ][0 ]['minfeefilter' ], Decimal ("0.00001000" ))
137
+ # check the `servicesnames` field
138
+ for info in peer_info :
139
+ assert_net_servicesnames (int (info [0 ]["services" ]), info [0 ]["servicesnames" ])
107
140
108
141
def _test_getnodeaddresses (self ):
109
142
self .nodes [0 ].add_p2p_connection (P2PInterface ())
0 commit comments