1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 14:58:09 +00:00
trezor-firmware/core/tests/common.py

33 lines
656 B
Python
Raw Normal View History

import sys
sys.path.append("../src")
import unittest # noqa: F401
from typing import Any, Awaitable
from ubinascii import hexlify, unhexlify # noqa: F401
from trezor import utils # noqa: F401
from apps.common.paths import HARDENED
2023-06-28 10:46:29 +00:00
def H_(x: int) -> int:
"""
Shortcut function that "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