mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
Merge #12545: test: Use wait_until to ensure ping goes out
0eb84f30d8
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
This commit is contained in:
commit
66e91420ab
@ -15,6 +15,7 @@ from test_framework.util import (
|
|||||||
assert_raises_rpc_error,
|
assert_raises_rpc_error,
|
||||||
connect_nodes_bi,
|
connect_nodes_bi,
|
||||||
p2p_port,
|
p2p_port,
|
||||||
|
wait_until,
|
||||||
)
|
)
|
||||||
|
|
||||||
class NetTest(BitcoinTestFramework):
|
class NetTest(BitcoinTestFramework):
|
||||||
@ -47,14 +48,13 @@ class NetTest(BitcoinTestFramework):
|
|||||||
# the bytes sent/received should change
|
# the bytes sent/received should change
|
||||||
# note ping and pong are 32 bytes each
|
# note ping and pong are 32 bytes each
|
||||||
self.nodes[0].ping()
|
self.nodes[0].ping()
|
||||||
time.sleep(0.1)
|
wait_until(lambda: (net_totals['totalbytessent'] + 32*2) == self.nodes[0].getnettotals()['totalbytessent'], timeout=1)
|
||||||
|
wait_until(lambda: (net_totals['totalbytesrecv'] + 32*2) == self.nodes[0].getnettotals()['totalbytesrecv'], timeout=1)
|
||||||
|
|
||||||
peer_info_after_ping = self.nodes[0].getpeerinfo()
|
peer_info_after_ping = self.nodes[0].getpeerinfo()
|
||||||
net_totals_after_ping = self.nodes[0].getnettotals()
|
|
||||||
for before, after in zip(peer_info, peer_info_after_ping):
|
for before, after in zip(peer_info, peer_info_after_ping):
|
||||||
assert_equal(before['bytesrecv_per_msg']['pong'] + 32, after['bytesrecv_per_msg']['pong'])
|
assert_equal(before['bytesrecv_per_msg']['pong'] + 32, after['bytesrecv_per_msg']['pong'])
|
||||||
assert_equal(before['bytessent_per_msg']['ping'] + 32, after['bytessent_per_msg']['ping'])
|
assert_equal(before['bytessent_per_msg']['ping'] + 32, after['bytessent_per_msg']['ping'])
|
||||||
assert_equal(net_totals['totalbytesrecv'] + 32*2, net_totals_after_ping['totalbytesrecv'])
|
|
||||||
assert_equal(net_totals['totalbytessent'] + 32*2, net_totals_after_ping['totalbytessent'])
|
|
||||||
|
|
||||||
def _test_getnetworkinginfo(self):
|
def _test_getnetworkinginfo(self):
|
||||||
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True)
|
assert_equal(self.nodes[0].getnetworkinfo()['networkactive'], True)
|
||||||
|
Loading…
Reference in New Issue
Block a user