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, factor=1.0): | timeout=float('inf'), lock=None, timeout_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 | timeout = 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 372 Lines • Show Last 20 Lines |