mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-29 02:48:18 +00:00
fixup: fix unit tests
This commit is contained in:
parent
385f52a726
commit
bcd68aecd9
@ -29,8 +29,15 @@ else:
|
|||||||
class TestApprover(unittest.TestCase):
|
class TestApprover(unittest.TestCase):
|
||||||
if utils.USE_THP:
|
if utils.USE_THP:
|
||||||
|
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
if __debug__:
|
||||||
|
thp_common.suppres_debug_log()
|
||||||
|
thp_common.prepare_context()
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
def setUpClass(self):
|
||||||
|
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
||||||
|
|
||||||
def tearDownClass(self):
|
def tearDownClass(self):
|
||||||
context.CURRENT_CONTEXT = None
|
context.CURRENT_CONTEXT = None
|
||||||
|
@ -18,12 +18,20 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
class TestAuthorization(unittest.TestCase):
|
class TestAuthorization(unittest.TestCase):
|
||||||
if utils.USE_THP:
|
|
||||||
|
|
||||||
coin = coins.by_name("Bitcoin")
|
coin = coins.by_name("Bitcoin")
|
||||||
|
|
||||||
def setUpClass(self):
|
if utils.USE_THP:
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
|
||||||
|
def setUpClass(self):
|
||||||
|
if __debug__:
|
||||||
|
thp_common.suppres_debug_log()
|
||||||
|
thp_common.prepare_context()
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
def setUpClass(self):
|
||||||
|
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
||||||
|
|
||||||
def tearDownClass(self):
|
def tearDownClass(self):
|
||||||
context.CURRENT_CONTEXT = None
|
context.CURRENT_CONTEXT = None
|
||||||
|
@ -15,13 +15,13 @@ else:
|
|||||||
|
|
||||||
|
|
||||||
class TestBitcoinKeychain(unittest.TestCase):
|
class TestBitcoinKeychain(unittest.TestCase):
|
||||||
|
|
||||||
if utils.USE_THP:
|
if utils.USE_THP:
|
||||||
|
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
if __debug__:
|
||||||
|
thp_common.suppres_debug_log()
|
||||||
def tearDownClass(self):
|
thp_common.prepare_context()
|
||||||
context.CURRENT_CONTEXT = None
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
seed = bip39.seed(" ".join(["all"] * 12), "")
|
seed = bip39.seed(" ".join(["all"] * 12), "")
|
||||||
@ -29,15 +29,17 @@ class TestBitcoinKeychain(unittest.TestCase):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
def __init__(self):
|
def setUpClass(self):
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
cache_codec.start_session()
|
cache_codec.start_session()
|
||||||
seed = bip39.seed(" ".join(["all"] * 12), "")
|
seed = bip39.seed(" ".join(["all"] * 12), "")
|
||||||
cache_codec.get_active_session().set(cache_common.APP_COMMON_SEED, seed)
|
cache_codec.get_active_session().set(cache_common.APP_COMMON_SEED, seed)
|
||||||
|
|
||||||
|
def tearDownClass(self):
|
||||||
|
context.CURRENT_CONTEXT = None
|
||||||
|
|
||||||
def test_bitcoin(self):
|
def test_bitcoin(self):
|
||||||
coin = _get_coin_by_name("Bitcoin")
|
coin = _get_coin_by_name("Bitcoin")
|
||||||
keychain = await_result(_get_keychain_for_coin(coin))
|
keychain = await_result(_get_keychain_for_coin(coin))
|
||||||
@ -113,19 +115,30 @@ class TestBitcoinKeychain(unittest.TestCase):
|
|||||||
|
|
||||||
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
|
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
|
||||||
class TestAltcoinKeychains(unittest.TestCase):
|
class TestAltcoinKeychains(unittest.TestCase):
|
||||||
if not utils.USE_THP:
|
if utils.USE_THP:
|
||||||
|
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
if __debug__:
|
||||||
|
thp_common.suppres_debug_log()
|
||||||
|
thp_common.prepare_context()
|
||||||
|
|
||||||
def tearDownClass(self):
|
def setUp(self):
|
||||||
context.CURRENT_CONTEXT = None
|
seed = bip39.seed(" ".join(["all"] * 12), "")
|
||||||
|
context.cache_set(cache_common.APP_COMMON_SEED, seed)
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
def setUpClass(self):
|
||||||
|
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
cache_codec.start_session()
|
cache_codec.start_session()
|
||||||
seed = bip39.seed(" ".join(["all"] * 12), "")
|
seed = bip39.seed(" ".join(["all"] * 12), "")
|
||||||
cache_codec.get_active_session().set(cache_common.APP_COMMON_SEED, seed)
|
cache_codec.get_active_session().set(cache_common.APP_COMMON_SEED, seed)
|
||||||
|
|
||||||
|
def tearDownClass(self):
|
||||||
|
context.CURRENT_CONTEXT = None
|
||||||
|
|
||||||
def test_bcash(self):
|
def test_bcash(self):
|
||||||
coin = _get_coin_by_name("Bcash")
|
coin = _get_coin_by_name("Bcash")
|
||||||
keychain = await_result(_get_keychain_for_coin(coin))
|
keychain = await_result(_get_keychain_for_coin(coin))
|
||||||
|
@ -2,7 +2,7 @@ from common import * # isort:skip
|
|||||||
|
|
||||||
from mock_storage import mock_storage
|
from mock_storage import mock_storage
|
||||||
from storage import cache, cache_common
|
from storage import cache, cache_common
|
||||||
from trezor import utils, wire
|
from trezor import wire
|
||||||
from trezor.crypto import bip39
|
from trezor.crypto import bip39
|
||||||
from trezor.enums import SafetyCheckLevel
|
from trezor.enums import SafetyCheckLevel
|
||||||
from trezor.wire import context
|
from trezor.wire import context
|
||||||
@ -20,27 +20,24 @@ if not utils.USE_THP:
|
|||||||
|
|
||||||
class TestKeychain(unittest.TestCase):
|
class TestKeychain(unittest.TestCase):
|
||||||
|
|
||||||
def setUpClass(self):
|
if utils.USE_THP:
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
|
||||||
|
|
||||||
def tearDownClass(self):
|
def setUpClass(self):
|
||||||
context.CURRENT_CONTEXT = None
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
thp_common.suppres_debug_log()
|
thp_common.suppres_debug_log()
|
||||||
thp_common.prepare_context()
|
thp_common.prepare_context()
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
def __init__(self):
|
def setUpClass(self):
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
cache_codec.start_session()
|
cache_codec.start_session()
|
||||||
|
|
||||||
|
def tearDownClass(self):
|
||||||
|
context.CURRENT_CONTEXT = None
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
cache.clear_all()
|
cache.clear_all()
|
||||||
|
|
||||||
|
@ -79,17 +79,12 @@ class TestEthereumKeychain(unittest.TestCase):
|
|||||||
addr,
|
addr,
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUpClass(self):
|
if utils.USE_THP:
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
|
||||||
|
|
||||||
def tearDownClass(self):
|
def setUpClass(self):
|
||||||
context.CURRENT_CONTEXT = None
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
thp_common.suppres_debug_log()
|
thp_common.suppres_debug_log()
|
||||||
thp_common.prepare_context()
|
thp_common.prepare_context()
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
seed = bip39.seed(" ".join(["all"] * 12), "")
|
seed = bip39.seed(" ".join(["all"] * 12), "")
|
||||||
@ -97,15 +92,17 @@ class TestEthereumKeychain(unittest.TestCase):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
def __init__(self):
|
def setUpClass(self):
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
cache_codec.start_session()
|
cache_codec.start_session()
|
||||||
seed = bip39.seed(" ".join(["all"] * 12), "")
|
seed = bip39.seed(" ".join(["all"] * 12), "")
|
||||||
cache_codec.get_active_session().set(cache_common.APP_COMMON_SEED, seed)
|
cache_codec.get_active_session().set(cache_common.APP_COMMON_SEED, seed)
|
||||||
|
|
||||||
|
def tearDownClass(self):
|
||||||
|
context.CURRENT_CONTEXT = None
|
||||||
|
|
||||||
def from_address_n(self, address_n):
|
def from_address_n(self, address_n):
|
||||||
slip44 = _slip44_from_address_n(address_n)
|
slip44 = _slip44_from_address_n(address_n)
|
||||||
network = make_network(slip44=slip44)
|
network = make_network(slip44=slip44)
|
||||||
|
@ -29,21 +29,11 @@ else:
|
|||||||
|
|
||||||
class TestStorageCache(unittest.TestCase):
|
class TestStorageCache(unittest.TestCase):
|
||||||
|
|
||||||
def setUpClass(self):
|
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
|
||||||
|
|
||||||
def tearDownClass(self):
|
|
||||||
context.CURRENT_CONTEXT = None
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
cache.clear_all()
|
|
||||||
|
|
||||||
if utils.USE_THP:
|
if utils.USE_THP:
|
||||||
|
|
||||||
def __init__(self):
|
def setUpClass(self):
|
||||||
thp_common.suppres_debug_log()
|
if __debug__:
|
||||||
# xthp_common.prepare_context()
|
thp_common.suppres_debug_log()
|
||||||
# config.init()
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -316,14 +306,19 @@ class TestStorageCache(unittest.TestCase):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
def __init__(self):
|
def setUpClass(self):
|
||||||
# Context is needed to test decorators and handleInitialize
|
|
||||||
# It allows access to codec cache from different parts of the code
|
|
||||||
from trezor.wire import context
|
|
||||||
from trezor.wire.codec.codec_context import CodecContext
|
from trezor.wire.codec.codec_context import CodecContext
|
||||||
|
from trezor.wire import context
|
||||||
|
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
||||||
super().__init__()
|
|
||||||
|
def tearDownClass(self):
|
||||||
|
from trezor.wire import context
|
||||||
|
|
||||||
|
context.CURRENT_CONTEXT = None
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
cache.clear_all()
|
||||||
|
|
||||||
def test_start_session(self):
|
def test_start_session(self):
|
||||||
session_id_a = cache_codec.start_session()
|
session_id_a = cache_codec.start_session()
|
||||||
|
Loading…
Reference in New Issue
Block a user