diff options
author | fanquake <fanquake@gmail.com> | 2020-09-03 11:47:08 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2020-09-03 12:07:53 +0800 |
commit | 136fe4c5e9fbaff1b461571c5f67d4fafe12c4ea (patch) | |
tree | f4c26f4a6c6b55092252964fcfd10ead78953a69 /test/functional/test_framework/util.py | |
parent | 9876ab8c74efe7cf7ebccb2b90b52e7b5957524f (diff) | |
parent | fa1cd9e1ddc6918c3d600d36eadea71eebb242b6 (diff) | |
download | bitcoin-136fe4c5e9fbaff1b461571c5f67d4fafe12c4ea.tar.xz |
Merge #19816: test: Rename wait until helper to wait_until_helper
fa1cd9e1ddc6918c3d600d36eadea71eebb242b6 test: Remove unused lock arg from BitcoinTestFramework.wait_until (MarcoFalke)
fad2794e93b4f5976e81793a4a63aa03a2c8c686 test: Rename wait until helper to wait_until_helper (MarcoFalke)
facb41bf1d1b7ee552c627f9829b4494b817ce28 test: Remove unused p2p_lock in VersionBitsWarningTest (MarcoFalke)
Pull request description:
This avoids confusion with the `wait_until` member functions, which should be preferred because they take the appropriate locks and scale the timeout appropriately on their own.
ACKs for top commit:
laanwj:
Code review ACK fa1cd9e1ddc6918c3d600d36eadea71eebb242b6
hebasto:
ACK fa1cd9e1ddc6918c3d600d36eadea71eebb242b6, I have reviewed the code and it looks OK, I agree it can be merged.
Tree-SHA512: 319d400085606a4c738e314824037f72998e6657d8622b363726842aba968744f23c56d27275dfe506b8cbbb6e97fc39ca1d325db05d4d67df0e8b35f2244d5c
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r-- | test/functional/test_framework/util.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index b9c7e89ac8..af7f0b62f4 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -226,14 +226,14 @@ def satoshi_round(amount): return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN) -def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=None, timeout_factor=1.0): +def wait_until_helper(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=None, timeout_factor=1.0): """Sleep until the predicate resolves to be True. Warning: Note that this method is not recommended to be used in tests as it is - not aware of the context of the test framework. Using `wait_until()` counterpart - from `BitcoinTestFramework` or `P2PInterface` class ensures an understandable - amount of timeout and a common shared timeout_factor. Furthermore, `wait_until()` - from `P2PInterface` class in `mininode.py` has a preset lock. + not aware of the context of the test framework. Using the `wait_until()` members + from `BitcoinTestFramework` or `P2PInterface` class ensures the timeout is + properly scaled. Furthermore, `wait_until()` from `P2PInterface` class in + `p2p.py` has a preset lock. """ if attempts == float('inf') and timeout == float('inf'): timeout = 60 @@ -438,7 +438,7 @@ def disconnect_nodes(from_connection, node_num): raise # wait to disconnect - wait_until(lambda: not get_peer_ids(), timeout=5) + wait_until_helper(lambda: not get_peer_ids(), timeout=5) def connect_nodes(from_connection, node_num): @@ -449,8 +449,8 @@ def connect_nodes(from_connection, node_num): # See comments in net_processing: # * Must have a version message before anything else # * Must have a verack message before anything else - wait_until(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo())) - wait_until(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo())) + wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo())) + wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo())) # Transaction/Block functions |