Skip to content

Commit 0eb84f3

Browse files
committed
test: Use wait_until to ensure ping goes out
Intermittent failure evident here: https://travis-ci.org/bitcoin/bitcoin/jobs/344021180
1 parent bf3353d commit 0eb84f3

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)