Skip to content

Commit cfef5a2

Browse files
committed
test: rpc_net.py logging and test naming improvements
1 parent 21c57ba commit cfef5a2

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

test/functional/rpc_net.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,27 @@ def set_test_params(self):
5151
self.supports_cli = False
5252

5353
def run_test(self):
54-
self.log.info('Get out of IBD for the minfeefilter and getpeerinfo tests')
54+
# Get out of IBD for the minfeefilter and getpeerinfo tests.
5555
self.nodes[0].generate(101)
56-
self.log.info('Connect nodes both way')
56+
# Connect nodes both ways.
5757
connect_nodes(self.nodes[0], 1)
5858
connect_nodes(self.nodes[1], 0)
5959

60-
self._test_connection_count()
61-
self._test_getpeerinfo()
62-
self._test_getnettotals()
63-
self._test_getnetworkinfo()
64-
self._test_getaddednodeinfo()
60+
self.test_connection_count()
61+
self.test_getpeerinfo()
62+
self.test_getnettotals()
63+
self.test_getnetworkinfo()
64+
self.test_getaddednodeinfo()
6565
self.test_service_flags()
66-
self._test_getnodeaddresses()
66+
self.test_getnodeaddresses()
6767

68-
def _test_connection_count(self):
69-
# connect_nodes connects each node to the other
68+
def test_connection_count(self):
69+
self.log.info("Test getconnectioncount")
70+
# After using `connect_nodes` to connect nodes 0 and 1 to each other.
7071
assert_equal(self.nodes[0].getconnectioncount(), 2)
7172

72-
def _test_getnettotals(self):
73+
def test_getnettotals(self):
74+
self.log.info("Test getnettotals")
7375
# getnettotals totalbytesrecv and totalbytessent should be
7476
# consistent with getpeerinfo. Since the RPC calls are not atomic,
7577
# and messages might have been recvd or sent between RPC calls, call
@@ -99,7 +101,8 @@ def _test_getnettotals(self):
99101
assert_greater_than_or_equal(after['bytesrecv_per_msg'].get('pong', 0), before['bytesrecv_per_msg'].get('pong', 0) + 32)
100102
assert_greater_than_or_equal(after['bytessent_per_msg'].get('ping', 0), before['bytessent_per_msg'].get('ping', 0) + 32)
101103

102-
def _test_getnetworkinfo(self):
104+
def test_getnetworkinfo(self):
105+
self.log.info("Test getnetworkinfo")
103106
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True)
104107
assert_equal(self.nodes[0].getnetworkinfo()['connections'], 2)
105108

@@ -111,7 +114,7 @@ def _test_getnetworkinfo(self):
111114

112115
with self.nodes[0].assert_debug_log(expected_msgs=['SetNetworkActive: true\n']):
113116
self.nodes[0].setnetworkactive(state=True)
114-
self.log.info('Connect nodes both way')
117+
# Connect nodes both ways.
115118
connect_nodes(self.nodes[0], 1)
116119
connect_nodes(self.nodes[1], 0)
117120

@@ -123,7 +126,8 @@ def _test_getnetworkinfo(self):
123126
for info in network_info:
124127
assert_net_servicesnames(int(info["localservices"], 0x10), info["localservicesnames"])
125128

126-
def _test_getaddednodeinfo(self):
129+
def test_getaddednodeinfo(self):
130+
self.log.info("Test getaddednodeinfo")
127131
assert_equal(self.nodes[0].getaddednodeinfo(), [])
128132
# add a node (node2) to node0
129133
ip_port = "127.0.0.1:{}".format(p2p_port(2))
@@ -142,7 +146,8 @@ def _test_getaddednodeinfo(self):
142146
# check that a non-existent node returns an error
143147
assert_raises_rpc_error(-24, "Node has not been added", self.nodes[0].getaddednodeinfo, '1.1.1.1')
144148

145-
def _test_getpeerinfo(self):
149+
def test_getpeerinfo(self):
150+
self.log.info("Test getpeerinfo")
146151
# Create a few getpeerinfo last_block/last_transaction values.
147152
if self.is_wallet_compiled():
148153
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1)
@@ -166,11 +171,13 @@ def _test_getpeerinfo(self):
166171
assert_net_servicesnames(int(info[0]["services"], 0x10), info[0]["servicesnames"])
167172

168173
def test_service_flags(self):
174+
self.log.info("Test service flags")
169175
self.nodes[0].add_p2p_connection(P2PInterface(), services=(1 << 4) | (1 << 63))
170176
assert_equal(['UNKNOWN[2^4]', 'UNKNOWN[2^63]'], self.nodes[0].getpeerinfo()[-1]['servicesnames'])
171177
self.nodes[0].disconnect_p2ps()
172178

173-
def _test_getnodeaddresses(self):
179+
def test_getnodeaddresses(self):
180+
self.log.info("Test getnodeaddresses")
174181
self.nodes[0].add_p2p_connection(P2PInterface())
175182

176183
# Add some addresses to the Address Manager over RPC. Due to the way

0 commit comments

Comments
 (0)