Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_node.py
Show First 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | def wait_for_rpc_connection(self): | ||||
self.host, | self.host, | ||||
self.rpc_port), | self.rpc_port), | ||||
self.index, | self.index, | ||||
timeout=self.rpc_timeout, | timeout=self.rpc_timeout, | ||||
coveragedir=self.coverage_dir) | coveragedir=self.coverage_dir) | ||||
rpc.getblockcount() | rpc.getblockcount() | ||||
# If the call to getblockcount() succeeds then the RPC | # If the call to getblockcount() succeeds then the RPC | ||||
# connection is up | # connection is up | ||||
wait_until(lambda: rpc.getmempoolinfo()['loaded']) | |||||
# Wait for the node to finish reindex, block import, and | |||||
# loading the mempool. Usually importing happens fast or | |||||
# even "immediate" when the node is started. However, there | |||||
# is no guarantee and sometimes ThreadImport might finish | |||||
# later. This is going to cause intermittent test failures, | |||||
# because generally the tests assume the node is fully | |||||
# ready after being started. | |||||
# | |||||
# For example, the node will reject block messages from p2p | |||||
# when it is still importing with the error "Unexpected | |||||
# block message received" | |||||
# | |||||
# The wait is done here to make tests as robust as possible | |||||
# and prevent racy tests and intermittent failures as much | |||||
# as possible. Some tests might not need this, but the | |||||
# overhead is trivial, and the added gurantees are worth | |||||
# the minimal performance cost. | |||||
self.log.debug("RPC successfully started") | self.log.debug("RPC successfully started") | ||||
if self.use_cli: | if self.use_cli: | ||||
return | return | ||||
self.rpc = rpc | self.rpc = rpc | ||||
self.rpc_connected = True | self.rpc_connected = True | ||||
self.url = self.rpc.url | self.url = self.rpc.url | ||||
return | return | ||||
except JSONRPCException as e: # Initialization phase | except JSONRPCException as e: # Initialization phase | ||||
▲ Show 20 Lines • Show All 417 Lines • Show Last 20 Lines |