diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-08-27 08:21:53 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-08-27 08:21:59 +0200 |
commit | 28f4e53e168fe09b3ed9b811f12e1f990a304264 (patch) | |
tree | 3a305ef0bd7831cf04418007dde502bf276ddd1a /test/functional/test_framework/util.py | |
parent | 30568d3f1e238f6900265914c2d449adcc355c66 (diff) | |
parent | d841301010914203fb5ef02627c76fad99cb11f1 (diff) | |
download | bitcoin-28f4e53e168fe09b3ed9b811f12e1f990a304264.tar.xz |
Merge #19752: test: Update wait_until usage in tests not to use the one from utils
d841301010914203fb5ef02627c76fad99cb11f1 test: Add docstring to wait_until() in util.py to warn about its usage (Seleme Topuz)
1343c86c7cc1fc896696b3ed87c12039e4ef3a0c test: Update wait_until usage in tests not to use the one from utils (Seleme Topuz)
Pull request description:
Replace global (from [test_framework/util.py](https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/util.py#L228)) `wait_until()` usages with the ones provided by `BitcoinTestFramework` and `P2PInterface` classes.
The motivation behind this change is that the `util.wait_until()` expects a timeout, timeout_factor and lock and it is not aware of the context of the test framework. `BitcoinTestFramework` offers a `wait_until()` which has an understandable amount of default `timeout` and a shared `timeout_factor`. Moreover, on top of these, `mininode.wait_until()` also has a shared lock.
closes #19080
ACKs for top commit:
MarcoFalke:
ACK d841301010914203fb5ef02627c76fad99cb11f1 🦆
kallewoof:
utACK d841301010914203fb5ef02627c76fad99cb11f1
Tree-SHA512: 81604f4cfa87fed98071a80e4afe940b3897fe65cf680a69619a93e97d45f25b313c12227de7040e19517fa9c003291b232f1b40b2567aba0148f22c23c47a88
Diffstat (limited to 'test/functional/test_framework/util.py')
-rw-r--r-- | test/functional/test_framework/util.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py index 3362b41209..cfc4ee65d4 100644 --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -226,6 +226,14 @@ def satoshi_round(amount): def wait_until(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. + """ if attempts == float('inf') and timeout == float('inf'): timeout = 60 timeout = timeout * timeout_factor |