Merge #20299: test: Fix intermittent rpc_net issue

fa2ecadd0d3283a89d27772dc0275e76277ae17e test: Fix intermittent rpc_net issue (MarcoFalke)

Pull request description:

  The test fails because getpeerinfo and getnettotals are not synchronised, so a `wait_until` is needed for each RPC (separately).

  Fixes https://cirrus-ci.com/task/4663366629195776?command=ci#L5034

ACKs for top commit:
  jnewbery:
    utACK fa2ecadd0d3283a89d27772dc0275e76277ae17e

Tree-SHA512: 5ea7128801aab8dbe3d9e6737545ff4ee770e4a9c5a2096ba2339a688424f1879ccba6bf8bcb219983acf86eb28af06fc629586613e7fe28aeffadd2c98633e8
This commit is contained in:
MarcoFalke 2020-11-04 17:16:38 +01:00 committed by pasta
parent 90419a4535
commit b747585486
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -19,7 +19,6 @@ from test_framework.test_framework import DashTestFramework
from test_framework.util import ( from test_framework.util import (
assert_approx, assert_approx,
assert_equal, assert_equal,
assert_greater_than_or_equal,
assert_greater_than, assert_greater_than,
assert_raises_rpc_error, assert_raises_rpc_error,
p2p_port, p2p_port,
@ -83,10 +82,10 @@ class NetTest(DashTestFramework):
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()['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) self.wait_until(lambda: (self.nodes[0].getnettotals()['totalbytesrecv'] >= net_totals_before['totalbytesrecv'] + 32 * 2), timeout=1)
peer_info_after = self.nodes[0].getpeerinfo() for peer_before in peer_info_before:
for before, after in zip(peer_info_before, peer_info_after): peer_after = lambda: next(p for p in self.nodes[0].getpeerinfo() if p['id'] == peer_before['id'])
assert_greater_than_or_equal(after['bytesrecv_per_msg'].get('pong', 0), before['bytesrecv_per_msg'].get('pong', 0) + 32) self.wait_until(lambda: peer_after()['bytesrecv_per_msg'].get('pong', 0) >= peer_before['bytesrecv_per_msg'].get('pong', 0) + 32, timeout=1)
assert_greater_than_or_equal(after['bytessent_per_msg'].get('ping', 0), before['bytessent_per_msg'].get('ping', 0) + 32) self.wait_until(lambda: peer_after()['bytessent_per_msg'].get('ping', 0) >= peer_before['bytessent_per_msg'].get('ping', 0) + 32, timeout=1)
def test_getnetworkinfo(self): def test_getnetworkinfo(self):
self.log.info("Test getnetworkinfo") self.log.info("Test getnetworkinfo")