mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-20 22:04:19 +02:00
Merge #11773: [tests] Change feature_block.py to use BitcoinTestFramework
265d7c4 [tests] Improve assert message when wait_until() fails (John Newbery) ebf053a [tests] Change feature_block.py to use BitcoinTestFramework (John Newbery) fc02c12 [tests] Add logging to feature_block.py (John Newbery) 3898c4f [tests] Tidy up feature_block.py (John Newbery) 5cd01d2 [tests] Fix flake8 warnings in feature_block.py (John Newbery) Pull request description: Next step in #10603. - first three commits tidy up feature_block.py - fourth commit removes usage of ComparisonTestFramework Longer term, it would be better to separate net_processing testing from validation testing, but I think this is still a useful PR, since it moves us away from the comparison test framework. Tree-SHA512: d0bb3ad22ad0aa1222877f4212bff075f9ce358e99c69c26d9913e4b346d931b8380e744434a9f6f37812c352cdaa75791691565bfeb18afcb619c06c6ca32a3
This commit is contained in:
commit
f0f9732d05
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@ from base64 import b64encode
|
|||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
from decimal import Decimal, ROUND_DOWN
|
from decimal import Decimal, ROUND_DOWN
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import inspect
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -204,9 +205,9 @@ def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=N
|
|||||||
if attempts == float('inf') and timeout == float('inf'):
|
if attempts == float('inf') and timeout == float('inf'):
|
||||||
timeout = 60
|
timeout = 60
|
||||||
attempt = 0
|
attempt = 0
|
||||||
timeout += time.time()
|
time_end = time.time() + timeout
|
||||||
|
|
||||||
while attempt < attempts and time.time() < timeout:
|
while attempt < attempts and time.time() < time_end:
|
||||||
if lock:
|
if lock:
|
||||||
with lock:
|
with lock:
|
||||||
if predicate():
|
if predicate():
|
||||||
@ -218,8 +219,12 @@ def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=N
|
|||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
||||||
# Print the cause of the timeout
|
# Print the cause of the timeout
|
||||||
assert_greater_than(attempts, attempt)
|
predicate_source = inspect.getsourcelines(predicate)
|
||||||
assert_greater_than(timeout, time.time())
|
logger.error("wait_until() failed. Predicate: {}".format(predicate_source))
|
||||||
|
if attempt >= attempts:
|
||||||
|
raise AssertionError("Predicate {} not true after {} attempts".format(predicate_source, attempts))
|
||||||
|
elif time.time() >= time_end:
|
||||||
|
raise AssertionError("Predicate {} not true after {} seconds".format(predicate_source, timeout))
|
||||||
raise RuntimeError('Unreachable')
|
raise RuntimeError('Unreachable')
|
||||||
|
|
||||||
# RPC/P2P connection constants and functions
|
# RPC/P2P connection constants and functions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user