Skip to content

Commit 66e9142

Browse files
author
MarcoFalke
committed
Merge #12545: test: Use wait_until to ensure ping goes out
0eb84f3 test: Use wait_until to ensure ping goes out (Ben Woosley) Pull request description: Intermittent failure evident here: https://travis-ci.org/bitcoin/bitcoin/jobs/344021180 Tree-SHA512: 8d3cbc55563160390d3918eb0b22348990cd81ad35c0563033f19142cb43b86a150fecc7df2196209ba00aaa805c67285451e582f387f8dac22d5e44d54e8a0d
2 parents d8d9162 + 0eb84f3 commit 66e9142

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/functional/rpc_net.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
assert_raises_rpc_error,
1616
connect_nodes_bi,
1717
p2p_port,
18+
wait_until,
1819
)
1920

2021
class NetTest(BitcoinTestFramework):
@@ -47,14 +48,13 @@ def _test_getnettotals(self):
4748
# the bytes sent/received should change
4849
# note ping and pong are 32 bytes each
4950
self.nodes[0].ping()
50-
time.sleep(0.1)
51+
wait_until(lambda: (net_totals['totalbytessent'] + 32*2) == self.nodes[0].getnettotals()['totalbytessent'], timeout=1)
52+
wait_until(lambda: (net_totals['totalbytesrecv'] + 32*2) == self.nodes[0].getnettotals()['totalbytesrecv'], timeout=1)
53+
5154
peer_info_after_ping = self.nodes[0].getpeerinfo()
52-
net_totals_after_ping = self.nodes[0].getnettotals()
5355
for before, after in zip(peer_info, peer_info_after_ping):
5456
assert_equal(before['bytesrecv_per_msg']['pong'] + 32, after['bytesrecv_per_msg']['pong'])
5557
assert_equal(before['bytessent_per_msg']['ping'] + 32, after['bytessent_per_msg']['ping'])
56-
assert_equal(net_totals['totalbytesrecv'] + 32*2, net_totals_after_ping['totalbytesrecv'])
57-
assert_equal(net_totals['totalbytessent'] + 32*2, net_totals_after_ping['totalbytessent'])
5858

5959
def _test_getnetworkinginfo(self):
6060
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True)

0 commit comments

Comments
 (0)