aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-10-28 16:27:26 +0100
committerMarcoFalke <falke.marco@gmail.com>2020-10-28 16:27:33 +0100
commit3f512f3d563954547061ee743648b57a900cbe04 (patch)
treea46f9cc97c8927f335b0cb2ee0bc34dab26253b2
parentdb26eeba71fb07caae8c4c8a59a80c4ebe0b5797 (diff)
parent778cd0d88d8d6dd22d7f0fb740f3ca3dbb2280a1 (diff)
Merge #20258: tests: Remove getnettotals/getpeerinfo consistency test
778cd0d88d8d6dd22d7f0fb740f3ca3dbb2280a1 [tests] Remove getnettotals/getpeerinfo consistency test (John Newbery) Pull request description: We make no guarantees about consistency between RPC calls. Alternative to 18784 ACKs for top commit: MarcoFalke: review ACK 778cd0d88d8d6dd22d7f0fb740f3ca3dbb2280a1 troygiorshev: ACK 778cd0d88d8d6dd22d7f0fb740f3ca3dbb2280a1 after reading discussion on 18784, code review, ran test Tree-SHA512: 438333a111cc93a09680cec47f13fbe03557d4803e5d826aec6f72e5afea62a088622645f0756e8fd2c9182c2a69ccca867d4d6fed2250364bee2b6c834adb1a
-rwxr-xr-xtest/functional/rpc_net.py32
1 files changed, 9 insertions, 23 deletions
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 03c858c694..034827b2b8 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -104,32 +104,18 @@ class NetTest(BitcoinTestFramework):
def test_getnettotals(self):
self.log.info("Test getnettotals")
- # getnettotals totalbytesrecv and totalbytessent should be
- # consistent with getpeerinfo. Since the RPC calls are not atomic,
- # and messages might have been recvd or sent between RPC calls, call
- # getnettotals before and after and verify that the returned values
- # from getpeerinfo are bounded by those values.
+ # Test getnettotals and getpeerinfo by doing a ping. The bytes
+ # sent/received should increase by at least the size of one ping (32
+ # bytes) and one pong (32 bytes).
net_totals_before = self.nodes[0].getnettotals()
- peer_info = self.nodes[0].getpeerinfo()
- net_totals_after = self.nodes[0].getnettotals()
- assert_equal(len(peer_info), 2)
- peers_recv = sum([peer['bytesrecv'] for peer in peer_info])
- peers_sent = sum([peer['bytessent'] for peer in peer_info])
-
- assert_greater_than_or_equal(peers_recv, net_totals_before['totalbytesrecv'])
- assert_greater_than_or_equal(net_totals_after['totalbytesrecv'], peers_recv)
- assert_greater_than_or_equal(peers_sent, net_totals_before['totalbytessent'])
- assert_greater_than_or_equal(net_totals_after['totalbytessent'], peers_sent)
-
- # test getnettotals and getpeerinfo by doing a ping
- # the bytes sent/received should change
- # note ping and pong are 32 bytes each
+ peer_info_before = self.nodes[0].getpeerinfo()
+
self.nodes[0].ping()
- self.wait_until(lambda: (self.nodes[0].getnettotals()['totalbytessent'] >= net_totals_after['totalbytessent'] + 32 * 2), timeout=1)
- self.wait_until(lambda: (self.nodes[0].getnettotals()['totalbytesrecv'] >= net_totals_after['totalbytesrecv'] + 32 * 2), timeout=1)
+ self.wait_until(lambda: (self.nodes[0].getnettotals()['totalbytessent'] >= net_totals_before['totalbytessent'] + 32 * 2), timeout=1)
+ self.wait_until(lambda: (self.nodes[0].getnettotals()['totalbytesrecv'] >= net_totals_before['totalbytesrecv'] + 32 * 2), timeout=1)
- peer_info_after_ping = self.nodes[0].getpeerinfo()
- for before, after in zip(peer_info, peer_info_after_ping):
+ peer_info_after = self.nodes[0].getpeerinfo()
+ for before, after in zip(peer_info_before, peer_info_after):
assert_greater_than_or_equal(after['bytesrecv_per_msg'].get('pong', 0), before['bytesrecv_per_msg'].get('pong', 0) + 32)
assert_greater_than_or_equal(after['bytessent_per_msg'].get('ping', 0), before['bytessent_per_msg'].get('ping', 0) + 32)