Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_node.py
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | def __getattr__(self, name): | ||||
"""Dispatches any unrecognised messages to the RPC connection or a CLI instance.""" | """Dispatches any unrecognised messages to the RPC connection or a CLI instance.""" | ||||
if self.use_cli: | if self.use_cli: | ||||
return getattr(self.cli, name) | return getattr(self.cli, name) | ||||
else: | else: | ||||
assert self.rpc is not None, "Error: RPC not initialized" | assert self.rpc is not None, "Error: RPC not initialized" | ||||
assert self.rpc_connected, "Error: No RPC connection" | assert self.rpc_connected, "Error: No RPC connection" | ||||
return getattr(self.rpc, name) | return getattr(self.rpc, name) | ||||
def start(self, extra_args=None, stderr=None): | def start(self, extra_args=None, stderr=None, *args, **kwargs): | ||||
"""Start the node.""" | """Start the node.""" | ||||
if extra_args is None: | if extra_args is None: | ||||
extra_args = self.extra_args | extra_args = self.extra_args | ||||
if stderr is None: | if stderr is None: | ||||
stderr = self.stderr | stderr = self.stderr | ||||
self.process = subprocess.Popen(self.args + extra_args, stderr=stderr) | self.process = subprocess.Popen( | ||||
self.args + extra_args, stderr=stderr, *args, **kwargs) | |||||
self.running = True | self.running = True | ||||
self.log.debug("bitcoind started, waiting for RPC to come up") | self.log.debug("bitcoind started, waiting for RPC to come up") | ||||
def wait_for_rpc_connection(self): | def wait_for_rpc_connection(self): | ||||
"""Sets up an RPC connection to the bitcoind process. Returns False if unable to connect.""" | """Sets up an RPC connection to the bitcoind process. Returns False if unable to connect.""" | ||||
# Poll at a rate of four times per second | # Poll at a rate of four times per second | ||||
poll_per_s = 4 | poll_per_s = 4 | ||||
for _ in range(poll_per_s * self.rpc_timeout): | for _ in range(poll_per_s * self.rpc_timeout): | ||||
▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines |