1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-27 08:58:28 +00:00
trezor-firmware/core/tests/common.py
2022-12-06 10:08:40 +01:00

40 lines
844 B
Python

import sys
sys.path.append("../src")
from ubinascii import hexlify, unhexlify # noqa: F401
import unittest # noqa: F401
from trezor import utils # noqa: F401
from apps.common.paths import HARDENED
COMMON_FIXTURES_DIR='/'.join(__file__.split('/')[0:-1])+"/../../common/tests/fixtures"
def H_(x: int) -> int:
"""
Shortcut function that "hardens" a number in a BIP44 path.
"""
return x | HARDENED
def UH_(x: int) -> int:
"""
Shortcut function that "un-hardens" a number in a BIP44 path.
"""
return x & ~(HARDENED)
def await_result(task: Awaitable) -> Any:
value = None
while True:
try:
result = task.send(value)
except StopIteration as e:
return e.value
if result:
value = await_result(result)
else:
value = None