Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/util.py
Show First 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | def str_to_b64str(string): | ||||
return b64encode(string.encode('utf-8')).decode('ascii') | return b64encode(string.encode('utf-8')).decode('ascii') | ||||
def satoshi_round(amount): | def satoshi_round(amount): | ||||
return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN) | return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN) | ||||
def wait_until(predicate, *, attempts=float('inf'), | def wait_until(predicate, *, attempts=float('inf'), | ||||
timeout=float('inf'), lock=None): | timeout=float('inf'), lock=None, factor=1.0): | ||||
if attempts == float('inf') and timeout == float('inf'): | if attempts == float('inf') and timeout == float('inf'): | ||||
timeout = 60 | timeout = 60 | ||||
timeout = timeout * factor | |||||
attempt = 0 | attempt = 0 | ||||
time_end = time.time() + timeout | time_end = time.time() + timeout | ||||
while attempt < attempts and time.time() < time_end: | while attempt < attempts and time.time() < time_end: | ||||
if lock: | if lock: | ||||
with lock: | with lock: | ||||
if predicate(): | if predicate(): | ||||
return | return | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | Kwargs: | ||||
coveragedir (str): Directory | coveragedir (str): Directory | ||||
Returns: | Returns: | ||||
AuthServiceProxy. convenience object for making RPC calls. | AuthServiceProxy. convenience object for making RPC calls. | ||||
""" | """ | ||||
proxy_kwargs = {} | proxy_kwargs = {} | ||||
if timeout is not None: | if timeout is not None: | ||||
proxy_kwargs['timeout'] = timeout | proxy_kwargs['timeout'] = int(timeout) | ||||
proxy = AuthServiceProxy(url, **proxy_kwargs) | proxy = AuthServiceProxy(url, **proxy_kwargs) | ||||
proxy.url = url # store URL on proxy for info | proxy.url = url # store URL on proxy for info | ||||
coverage_logfile = coverage.get_filename( | coverage_logfile = coverage.get_filename( | ||||
coveragedir, node_number) if coveragedir else None | coveragedir, node_number) if coveragedir else None | ||||
return coverage.AuthServiceProxyWrapper(proxy, coverage_logfile) | return coverage.AuthServiceProxyWrapper(proxy, coverage_logfile) | ||||
▲ Show 20 Lines • Show All 312 Lines • Show Last 20 Lines |