Skip to content

Commit

Permalink
fixup test rpc args
Browse files Browse the repository at this point in the history
  • Loading branch information
willcl-ark committed Nov 22, 2023
1 parent 2a9b6db commit 0341129
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/functional/rpc_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,27 +195,27 @@ def test_getnetmsgstats(self):
getnetmsgstats_response['totals']['byte_count'])

# Test aggregation of results by trying out a few different combinations
getnetmsgstats_msgtype = self.nodes[0].getnetmsgstats(show_only=["direction", "message_type"])
getnetmsgstats_msgtype = self.nodes[0].getnetmsgstats(group_by=["direction", "message_type"])
assert_array_result([getnetmsgstats_msgtype['sent']['ping']], {'message_count': 4}, {'byte_count': 128})
assert_array_result([getnetmsgstats_msgtype['received']['pong']], {'message_count': 4}, {'byte_count': 128})

getnetmsgstats_conntype_msgtype = self.nodes[0].getnetmsgstats(show_only=["direction", "connection_type", "message_type"])
getnetmsgstats_conntype_msgtype = self.nodes[0].getnetmsgstats(group_by=["direction", "connection_type", "message_type"])
assert_array_result([getnetmsgstats_conntype_msgtype['received']['manual']['pong']], {'message_count': 2}, {'byte_count': 64})

getnetmsgstats_conntype_msgtype_network = self.nodes[0].getnetmsgstats(show_only=["direction", "connection_type",
getnetmsgstats_conntype_msgtype_network = self.nodes[0].getnetmsgstats(group_by=["direction", "connection_type",
"message_type", "network"])
manualconn_sendaddrv2_stats = [{'message_count': 1}, {'byte_count': 24}]
assert_array_result([getnetmsgstats_conntype_msgtype_network['sent']['manual']['sendaddrv2']['not_publicly_routable']],
manualconn_sendaddrv2_stats[0], manualconn_sendaddrv2_stats[1])

# stats should be the same as the previous test, even with the dimension types reordered
getnetmsgstats_network_conntype_msgtype = self.nodes[0].getnetmsgstats(show_only=["direction", "network",
getnetmsgstats_network_conntype_msgtype = self.nodes[0].getnetmsgstats(group_by=["direction", "network",
"connection_type", "message_type"])
assert_array_result([getnetmsgstats_network_conntype_msgtype['sent']['not_publicly_routable']['manual']['sendaddrv2']],
manualconn_sendaddrv2_stats[0], manualconn_sendaddrv2_stats[1])

# check that the breakdown of sent ping messages matches the results that only show message type
getnetmsgstats_msgtype_conntype = self.nodes[0].getnetmsgstats(show_only=["direction", "message_type", "connection_type"])
getnetmsgstats_msgtype_conntype = self.nodes[0].getnetmsgstats(group_by=["direction", "message_type", "connection_type"])
sent_ping_inbound = getnetmsgstats_msgtype_conntype['sent']['ping']['inbound']
sent_ping_manual = getnetmsgstats_msgtype_conntype['sent']['ping']['manual']
assert_equal(sent_ping_inbound['message_count'] + sent_ping_manual['message_count'],
Expand All @@ -235,15 +235,15 @@ def test_getnetmsgstats(self):
# ping() sends a ping to all other nodes, so message count increases by at least two pings.
# One for peer0 and one for peer1
self.nodes[0].ping()
self.wait_until(lambda: (self.nodes[0].getnetmsgstats(show_only=["direction", "message_type"])
self.wait_until(lambda: (self.nodes[0].getnetmsgstats(group_by=["direction", "message_type"])
['sent']['ping']['message_count'] >= total_sent_ping_stats['message_count'] + 1), timeout=1)
self.wait_until(lambda: (self.nodes[0].getnetmsgstats(show_only=["direction", "message_type"])
self.wait_until(lambda: (self.nodes[0].getnetmsgstats(group_by=["direction", "message_type"])
['received']['pong']['message_count'] >= total_received_pong_stats['message_count'] + 1), timeout=1)

getnetmsgstats_sent_ping = self.nodes[0].getnetmsgstats(show_only=["direction", "message_type"])['sent']['ping']
getnetmsgstats_sent_ping = self.nodes[0].getnetmsgstats(group_by=["direction", "message_type"])['sent']['ping']
assert_greater_than_or_equal(getnetmsgstats_sent_ping['byte_count'], total_sent_ping_stats['byte_count'] + 2 * 32)

getnetmsgstats_received_pong = self.nodes[0].getnetmsgstats(show_only=["direction", "message_type"])['received']['pong']
getnetmsgstats_received_pong = self.nodes[0].getnetmsgstats(group_by=["direction", "message_type"])['received']['pong']
assert_greater_than_or_equal(getnetmsgstats_received_pong['byte_count'], total_received_pong_stats['byte_count'] + 2 * 32)

# Test that when a message is broken in two, the stats only update once the full message has been received
Expand All @@ -253,7 +253,7 @@ def test_getnetmsgstats(self):
cut_pos = 12 # Chosen at an arbitrary position within the header
# Send message in two pieces
getnettotals_before_partial_ping = self.nodes[0].getnettotals()['totalbytesrecv']
netmsgstats_before_partial_ping = self.nodes[0].getnetmsgstats(show_only=["direction", "message_type"])['received']['ping']
netmsgstats_before_partial_ping = self.nodes[0].getnetmsgstats(group_by=["direction", "message_type"])['received']['ping']

conn.send_raw_message(ping_msg[:cut_pos])
# getnettotals gets updated even for partial messages
Expand All @@ -264,14 +264,14 @@ def test_getnetmsgstats(self):
assert_equal(getnettotals_partial_ping, getnettotals_before_partial_ping + cut_pos)

# check that getnetmsgstats did not update
getnetmsgstats_after_partial_ping = self.nodes[0].getnetmsgstats(show_only=["direction", "message_type"])['received']['ping']
getnetmsgstats_after_partial_ping = self.nodes[0].getnetmsgstats(group_by=["direction", "message_type"])['received']['ping']
assert_equal(getnetmsgstats_after_partial_ping['message_count'], netmsgstats_before_partial_ping['message_count'])
assert_equal(getnetmsgstats_after_partial_ping['byte_count'], netmsgstats_before_partial_ping['byte_count'])

# send the rest of the ping
conn.send_raw_message(ping_msg[cut_pos:])
self.wait_until(lambda: self.nodes[0].getnettotals()['totalbytesrecv'] > getnettotals_partial_ping)
getnetmsgstats_finished_ping = self.nodes[0].getnetmsgstats(show_only=["direction", "message_type"])['received']['ping']
getnetmsgstats_finished_ping = self.nodes[0].getnetmsgstats(group_by=["direction", "message_type"])['received']['ping']
assert_equal(getnetmsgstats_finished_ping['message_count'], netmsgstats_before_partial_ping['message_count'] + 1)
assert_equal(getnetmsgstats_finished_ping['byte_count'], netmsgstats_before_partial_ping['byte_count'] + 32)

Expand Down

0 comments on commit 0341129

Please sign in to comment.