From 33b5436dcc58cbd66b51b1006e644f05b7a8f765 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sun, 6 Nov 2016 17:04:25 +0100 Subject: [PATCH] tests: move to /tests to avoid freezing --- Makefile | 2 +- src/trezor/config.py | 5 +++++ {src/tests => tests}/check_coverage.sh | 4 ++-- tests/common.py | 8 ++++++++ {src/tests => tests}/run_tests.sh | 2 +- {src/tests => tests}/test_trezor.config.py | 8 +++----- {src/tests => tests}/test_trezor.crypto.aes.py | 6 +----- {src/tests => tests}/test_trezor.crypto.base58.py | 9 +++------ {src/tests => tests}/test_trezor.crypto.bip32.py | 7 +------ {src/tests => tests}/test_trezor.crypto.bip39.py | 6 +----- .../test_trezor.crypto.curve.curve25519.py | 6 +----- .../test_trezor.crypto.curve.ed25519.py | 9 +++------ .../test_trezor.crypto.curve.nist256p1.py | 9 +++------ .../test_trezor.crypto.curve.secp256k1.py | 9 +++------ .../test_trezor.crypto.hashlib.blake2s.py | 6 +----- .../test_trezor.crypto.hashlib.ripemd160.py | 6 +----- .../test_trezor.crypto.hashlib.sha1.py | 6 +----- .../test_trezor.crypto.hashlib.sha256.py | 6 +----- .../test_trezor.crypto.hashlib.sha3_256.py | 6 +----- .../test_trezor.crypto.hashlib.sha3_512.py | 6 +----- .../test_trezor.crypto.hashlib.sha512.py | 6 +----- {src/tests => tests}/test_trezor.crypto.hmac.py | 7 ++----- {src/tests => tests}/test_trezor.crypto.pbkdf2.py | 6 +----- {src/tests => tests}/test_trezor.crypto.random.py | 6 +----- {src/tests => tests}/test_trezor.debug.py | 5 +---- {src/tests => tests}/test_trezor.utils.py | 5 +---- {src/tests => tests}/test_trezor.wire.wire_codec.py | 10 ++++------ .../test_trezor.wire.wire_codec_v1.py | 13 ++++++------- 28 files changed, 59 insertions(+), 125 deletions(-) rename {src/tests => tests}/check_coverage.sh (82%) create mode 100644 tests/common.py rename {src/tests => tests}/run_tests.sh (82%) rename {src/tests => tests}/test_trezor.config.py (90%) rename {src/tests => tests}/test_trezor.crypto.aes.py (95%) rename {src/tests => tests}/test_trezor.crypto.base58.py (98%) rename {src/tests => tests}/test_trezor.crypto.bip32.py (98%) rename {src/tests => tests}/test_trezor.crypto.bip39.py (99%) rename {src/tests => tests}/test_trezor.crypto.curve.curve25519.py (91%) rename {src/tests => tests}/test_trezor.crypto.curve.ed25519.py (97%) rename {src/tests => tests}/test_trezor.crypto.curve.nist256p1.py (98%) rename {src/tests => tests}/test_trezor.crypto.curve.secp256k1.py (98%) rename {src/tests => tests}/test_trezor.crypto.hashlib.blake2s.py (96%) rename {src/tests => tests}/test_trezor.crypto.hashlib.ripemd160.py (96%) rename {src/tests => tests}/test_trezor.crypto.hashlib.sha1.py (95%) rename {src/tests => tests}/test_trezor.crypto.hashlib.sha256.py (95%) rename {src/tests => tests}/test_trezor.crypto.hashlib.sha3_256.py (96%) rename {src/tests => tests}/test_trezor.crypto.hashlib.sha3_512.py (97%) rename {src/tests => tests}/test_trezor.crypto.hashlib.sha512.py (96%) rename {src/tests => tests}/test_trezor.crypto.hmac.py (97%) rename {src/tests => tests}/test_trezor.crypto.pbkdf2.py (97%) rename {src/tests => tests}/test_trezor.crypto.random.py (92%) rename {src/tests => tests}/test_trezor.debug.py (80%) rename {src/tests => tests}/test_trezor.utils.py (87%) rename {src/tests => tests}/test_trezor.wire.wire_codec.py (99%) rename {src/tests => tests}/test_trezor.wire.wire_codec_v1.py (98%) diff --git a/Makefile b/Makefile index 46c37a387..4e795d2a5 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ clean_cross: ## clean mpy-cross build $(MAKE) -C vendor/micropython/mpy-cross clean test: ## run unit tests - cd src/tests ; ./run_tests.sh + cd tests ; ./run_tests.sh flash: ## flash firmware using st-flash st-flash write $(STMHAL_BUILD_DIR)/firmware0.bin 0x8000000 diff --git a/src/trezor/config.py b/src/trezor/config.py index a342d040b..e7babd2ff 100644 --- a/src/trezor/config.py +++ b/src/trezor/config.py @@ -12,6 +12,7 @@ else: def _load(): + global _mock try: with open(_file, 'rb') as f: while True: @@ -26,6 +27,7 @@ def _load(): def _save(): + global _mock with open(_file, 'wb') as f: for k, v in _mock.items(): f.write(ustruct.pack('