From dbec3af810851666ba16e3c9b9e966974fcb0aa5 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 28 May 2018 14:02:07 +0200 Subject: [PATCH] tests: introduce FAST_TESTS flag for faster local testing --- lib/tests/__init__.py | 7 +++++++ lib/tests/test_bitcoin.py | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/tests/__init__.py b/lib/tests/__init__.py index 919a49b22..f10adee50 100644 --- a/lib/tests/__init__.py +++ b/lib/tests/__init__.py @@ -4,6 +4,13 @@ import threading from lib import constants +# Set this locally to make the test suite run faster. +# If set, unit tests that would normally test functions with multiple implementations, +# will only be run once, using the fastest implementation. +# e.g. libsecp256k1 vs python-ecdsa. pycryptodomex vs pyaes. +FAST_TESTS = False + + # some unit tests are modifying globals; sorry. class SequentialTestCase(unittest.TestCase): diff --git a/lib/tests/test_bitcoin.py b/lib/tests/test_bitcoin.py index 60b8bbebe..6555fff6a 100644 --- a/lib/tests/test_bitcoin.py +++ b/lib/tests/test_bitcoin.py @@ -21,8 +21,8 @@ from lib import constants from lib.storage import WalletStorage from . import SequentialTestCase - from . import TestCaseForTestnet +from . import FAST_TESTS try: @@ -39,6 +39,9 @@ def needs_test_with_all_ecc_implementations(func): tests running in parallel would break things """ def run_test(*args, **kwargs): + if FAST_TESTS: # if set, only run tests once, using fastest implementation + func(*args, **kwargs) + return ecc_fast.undo_monkey_patching_of_python_ecdsa_internals_with_libsecp256k1() try: # first test without libsecp @@ -61,6 +64,9 @@ def needs_test_with_all_aes_implementations(func): tests running in parallel would break things """ def run_test(*args, **kwargs): + if FAST_TESTS: # if set, only run tests once, using fastest implementation + func(*args, **kwargs) + return _aes = crypto.AES crypto.AES = None try: