mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-26 16:18:22 +00:00
tests: move to /tests to avoid freezing
This commit is contained in:
parent
c95ed063db
commit
33b5436dcc
2
Makefile
2
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
|
||||
|
@ -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('<HH', k, len(v)))
|
||||
@ -35,13 +37,16 @@ _load()
|
||||
|
||||
|
||||
def get(app_id, key, default=None):
|
||||
global _mock
|
||||
return _mock.get((app_id << 8) | key, default)
|
||||
|
||||
|
||||
def set(app_id, key, value):
|
||||
global _mock
|
||||
_mock[(app_id << 8) | key] = value
|
||||
_save()
|
||||
|
||||
def wipe():
|
||||
global _mock
|
||||
_mock = {}
|
||||
_save()
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
find ../../mocks -name '*.py' | sort | while read module; do
|
||||
module=$(echo $module | sed 's:^\.\./\.\./mocks/::')
|
||||
find ../mocks -name '*.py' | sort | while read module; do
|
||||
module=$(echo $module | sed 's:^\.\./mocks/::')
|
||||
base=$(basename $module)
|
||||
# skip __init__.py
|
||||
if [[ $base == "__init__.py" ]]; then
|
8
tests/common.py
Normal file
8
tests/common.py
Normal file
@ -0,0 +1,8 @@
|
||||
import sys
|
||||
|
||||
sys.path.append('../src')
|
||||
sys.path.append('../src/lib')
|
||||
|
||||
import unittest
|
||||
|
||||
from ubinascii import hexlify, unhexlify
|
@ -8,7 +8,7 @@ else
|
||||
fi
|
||||
for i in $list; do
|
||||
echo
|
||||
if ../../vendor/micropython/unix/micropython $i; then
|
||||
if ../vendor/micropython/unix/micropython $i; then
|
||||
results+=("OK $i")
|
||||
else
|
||||
results+=("FAIL $i")
|
@ -1,10 +1,8 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import random
|
||||
|
||||
from trezor import config
|
||||
from trezor.crypto import random
|
||||
|
||||
class TestConfig(unittest.TestCase):
|
||||
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto.aes import *
|
||||
|
@ -1,11 +1,8 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto.hashlib import ripemd160
|
||||
|
||||
from trezor.crypto import base58
|
||||
from trezor.crypto.hashlib import ripemd160
|
||||
|
||||
digestfunc_graphene = lambda x: ripemd160(x).digest()[:4]
|
||||
|
@ -1,14 +1,9 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import bip32
|
||||
|
||||
SECP256K1_NAME = 'secp256k1'
|
||||
|
||||
|
||||
class TestCryptoBip32(unittest.TestCase):
|
||||
|
||||
def test_from_seed_invalid(self):
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import bip39
|
||||
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto.curve import curve25519
|
||||
|
@ -1,11 +1,8 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import random
|
||||
|
||||
from trezor.crypto.curve import ed25519
|
||||
from trezor.crypto import random
|
||||
|
||||
class TestCryptoEd25519(unittest.TestCase):
|
||||
|
@ -1,11 +1,8 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import hexlify, unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import random
|
||||
|
||||
from trezor.crypto.curve import nist256p1
|
||||
from trezor.crypto import random
|
||||
|
||||
class TestCryptoNist256p1(unittest.TestCase):
|
||||
|
@ -1,11 +1,8 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import hexlify, unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import random
|
||||
|
||||
from trezor.crypto.curve import secp256k1
|
||||
from trezor.crypto import random
|
||||
|
||||
class TestCryptoSecp256k1(unittest.TestCase):
|
||||
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import hashlib
|
||||
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import hashlib
|
||||
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import hashlib
|
||||
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import hashlib
|
||||
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import hashlib
|
||||
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import hashlib
|
||||
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import hashlib
|
||||
|
@ -1,10 +1,7 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import hashlib
|
||||
|
||||
from trezor.crypto import hmac
|
||||
|
||||
class TestCryptoHmac(unittest.TestCase):
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import unhexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import pbkdf2
|
||||
|
@ -1,8 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from ubinascii import hexlify
|
||||
from common import *
|
||||
|
||||
from trezor.crypto import random
|
||||
|
@ -1,7 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from common import *
|
||||
|
||||
from trezor import debug
|
||||
|
@ -1,7 +1,4 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from common import *
|
||||
|
||||
from trezor import utils
|
||||
|
@ -1,14 +1,12 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from common import *
|
||||
|
||||
import ustruct
|
||||
import ubinascii
|
||||
|
||||
from trezor.wire import wire_codec
|
||||
from trezor.utils import chunks
|
||||
from trezor.crypto import random
|
||||
from trezor.utils import chunks
|
||||
|
||||
from trezor.wire import wire_codec
|
||||
|
||||
class TestWireCodec(unittest.TestCase):
|
||||
# pylint: disable=C0301
|
@ -1,13 +1,12 @@
|
||||
import sys
|
||||
sys.path.append('..')
|
||||
sys.path.append('../lib')
|
||||
import unittest
|
||||
from common import *
|
||||
|
||||
import ustruct
|
||||
import ubinascii
|
||||
|
||||
from trezor.crypto import random
|
||||
from trezor.utils import chunks
|
||||
|
||||
from trezor.wire import wire_codec_v1
|
||||
from trezor.utils import chunks
|
||||
from trezor.crypto import random
|
||||
|
||||
|
||||
class TestWireCodecV1(unittest.TestCase):
|
||||
# pylint: disable=C0301
|
Loading…
Reference in New Issue
Block a user