mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
fix style after rebase
This commit is contained in:
parent
abbbbd0159
commit
8256fc845f
@ -129,7 +129,7 @@ async def _prepare_pairing(ctx: PairingContext) -> None:
|
|||||||
async def show_display_data(
|
async def show_display_data(
|
||||||
ctx: PairingContext, expected_types: Container[int] = ()
|
ctx: PairingContext, expected_types: Container[int] = ()
|
||||||
) -> type[protobuf.MessageType]:
|
) -> type[protobuf.MessageType]:
|
||||||
from trezorui2 import CANCELLED
|
from trezorui_api import CANCELLED
|
||||||
|
|
||||||
read_task = ctx.read(expected_types)
|
read_task = ctx.read(expected_types)
|
||||||
cancel_task = ctx.display_data.get_display_layout()
|
cancel_task = ctx.display_data.get_display_layout()
|
||||||
|
@ -132,7 +132,7 @@ class Channel:
|
|||||||
# TODO Check CRC and if valid, check tag, if valid update nonces
|
# TODO Check CRC and if valid, check tag, if valid update nonces
|
||||||
self._finish_fallback()
|
self._finish_fallback()
|
||||||
# TODO self.write() failure device is busy - use channel buffer to send this failure message!!
|
# TODO self.write() failure device is busy - use channel buffer to send this failure message!!
|
||||||
return
|
return None
|
||||||
return received_message_handler.handle_received_message(self, buffer)
|
return received_message_handler.handle_received_message(self, buffer)
|
||||||
elif self.expected_payload_length + INIT_HEADER_LENGTH > self.bytes_read:
|
elif self.expected_payload_length + INIT_HEADER_LENGTH > self.bytes_read:
|
||||||
self.is_cont_packet_expected = True
|
self.is_cont_packet_expected = True
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
from ubinascii import hexlify
|
from ubinascii import hexlify
|
||||||
|
|
||||||
import trezorui2
|
import trezorui_api
|
||||||
from trezor import loop, protobuf, workflow
|
from trezor import loop, protobuf, workflow
|
||||||
from trezor.crypto import random
|
from trezor.crypto import random
|
||||||
from trezor.wire import context, message_handler, protocol_common
|
from trezor.wire import context, message_handler, protocol_common
|
||||||
@ -42,7 +42,7 @@ class PairingDisplayData:
|
|||||||
code_str = self._get_code_code_entry_str()
|
code_str = self._get_code_code_entry_str()
|
||||||
|
|
||||||
return ui.Layout(
|
return ui.Layout(
|
||||||
trezorui2.show_address_details( # noqa
|
trezorui_api.show_address_details( # noqa
|
||||||
qr_title="Scan QR code to pair",
|
qr_title="Scan QR code to pair",
|
||||||
address=qr_str,
|
address=qr_str,
|
||||||
case_sensitive=True,
|
case_sensitive=True,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: F403,F405
|
||||||
from common import * # isort:skip
|
from common import * # isort:skip
|
||||||
|
|
||||||
import storage.cache_codec
|
import storage.cache_codec
|
||||||
@ -12,13 +13,13 @@ from trezor.messages import (
|
|||||||
TxOutput,
|
TxOutput,
|
||||||
)
|
)
|
||||||
from trezor.wire import context
|
from trezor.wire import context
|
||||||
|
from trezor.wire.codec.codec_context import CodecContext
|
||||||
|
|
||||||
from apps.bitcoin.authorization import FEE_RATE_DECIMALS, CoinJoinAuthorization
|
from apps.bitcoin.authorization import FEE_RATE_DECIMALS, CoinJoinAuthorization
|
||||||
from apps.bitcoin.sign_tx.approvers import CoinJoinApprover
|
from apps.bitcoin.sign_tx.approvers import CoinJoinApprover
|
||||||
from apps.bitcoin.sign_tx.bitcoin import Bitcoin
|
from apps.bitcoin.sign_tx.bitcoin import Bitcoin
|
||||||
from apps.bitcoin.sign_tx.tx_info import TxInfo
|
from apps.bitcoin.sign_tx.tx_info import TxInfo
|
||||||
from apps.common import coins
|
from apps.common import coins
|
||||||
from trezor.wire.codec.codec_context import CodecContext
|
|
||||||
|
|
||||||
if utils.USE_THP:
|
if utils.USE_THP:
|
||||||
import thp_common
|
import thp_common
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: F403,F405
|
||||||
from common import * # isort:skip
|
from common import * # isort:skip
|
||||||
|
|
||||||
import storage.cache_codec
|
import storage.cache_codec
|
||||||
|
@ -14,10 +14,11 @@ if utils.USE_THP:
|
|||||||
_PROTOCOL_CACHE = cache_thp
|
_PROTOCOL_CACHE = cache_thp
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
from mock_storage import mock_storage
|
||||||
from storage import cache, cache_codec
|
from storage import cache, cache_codec
|
||||||
from trezor.messages import EndSession, Initialize
|
from trezor.messages import EndSession, Initialize
|
||||||
|
|
||||||
from apps.base import handle_EndSession
|
from apps.base import handle_EndSession
|
||||||
from mock_storage import mock_storage
|
|
||||||
|
|
||||||
_PROTOCOL_CACHE = cache_codec
|
_PROTOCOL_CACHE = cache_codec
|
||||||
|
|
||||||
@ -319,8 +320,8 @@ class TestStorageCache(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
|
|
||||||
def setUpClass(self):
|
def setUpClass(self):
|
||||||
from trezor.wire.codec.codec_context import CodecContext
|
|
||||||
from trezor.wire import context
|
from trezor.wire import context
|
||||||
|
from trezor.wire.codec.codec_context import CodecContext
|
||||||
|
|
||||||
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
context.CURRENT_CONTEXT = CodecContext(None, bytearray(64))
|
||||||
|
|
||||||
@ -377,7 +378,7 @@ class TestStorageCache(unittest.TestCase):
|
|||||||
session_id = cache_codec.start_session()
|
session_id = cache_codec.start_session()
|
||||||
self.assertEqual(cache_codec.start_session(session_id), session_id)
|
self.assertEqual(cache_codec.start_session(session_id), session_id)
|
||||||
get_active_session().set(KEY, b"A")
|
get_active_session().set(KEY, b"A")
|
||||||
for i in range(_PROTOCOL_CACHE._MAX_SESSIONS_COUNT):
|
for _ in range(_PROTOCOL_CACHE._MAX_SESSIONS_COUNT):
|
||||||
cache_codec.start_session()
|
cache_codec.start_session()
|
||||||
self.assertNotEqual(cache_codec.start_session(session_id), session_id)
|
self.assertNotEqual(cache_codec.start_session(session_id), session_id)
|
||||||
self.assertIsNone(get_active_session().get(KEY))
|
self.assertIsNone(get_active_session().get(KEY))
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: F403,F405
|
||||||
from common import * # isort:skip
|
from common import * # isort:skip
|
||||||
|
|
||||||
if utils.USE_THP:
|
if utils.USE_THP:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: F403,F405
|
||||||
from common import * # isort:skip
|
from common import * # isort:skip
|
||||||
from trezorcrypto import aesgcm, curve25519
|
from trezorcrypto import aesgcm, curve25519
|
||||||
|
|
||||||
@ -101,8 +102,8 @@ class TestTrezorHostProtocolCrypto(unittest.TestCase):
|
|||||||
|
|
||||||
def test_iv_from_nonce(self):
|
def test_iv_from_nonce(self):
|
||||||
for v in self.vectors_iv:
|
for v in self.vectors_iv:
|
||||||
x = v[0]
|
# x = v[0]
|
||||||
y = x.to_bytes(8, "big")
|
# y = x.to_bytes(8, "big")
|
||||||
iv = crypto._get_iv_from_nonce(v[0])
|
iv = crypto._get_iv_from_nonce(v[0])
|
||||||
self.assertEqual(iv, v[1])
|
self.assertEqual(iv, v[1])
|
||||||
with self.assertRaises(AssertionError) as e:
|
with self.assertRaises(AssertionError) as e:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: F403,F405
|
||||||
from common import * # isort:skip
|
from common import * # isort:skip
|
||||||
from mock_wire_interface import MockHID
|
from mock_wire_interface import MockHID
|
||||||
from trezor import config, io, protobuf
|
from trezor import config, io, protobuf
|
||||||
@ -28,8 +29,13 @@ if utils.USE_THP:
|
|||||||
ThpEndRequest,
|
ThpEndRequest,
|
||||||
ThpStartPairingRequest,
|
ThpStartPairingRequest,
|
||||||
)
|
)
|
||||||
from trezor.wire.thp import thp_main, memory_manager
|
from trezor.wire.thp import (
|
||||||
from trezor.wire.thp import ChannelState, checksum, interface_manager
|
ChannelState,
|
||||||
|
checksum,
|
||||||
|
interface_manager,
|
||||||
|
memory_manager,
|
||||||
|
thp_main,
|
||||||
|
)
|
||||||
from trezor.wire.thp.crypto import Handshake
|
from trezor.wire.thp.crypto import Handshake
|
||||||
from trezor.wire.thp.pairing_context import PairingContext
|
from trezor.wire.thp.pairing_context import PairingContext
|
||||||
|
|
||||||
@ -251,7 +257,7 @@ class TestTrezorHostProtocol(unittest.TestCase):
|
|||||||
|
|
||||||
# test invalid tag in handshake phase
|
# test invalid tag in handshake phase
|
||||||
cid_2 = get_channel_id_from_response(expected_response_1)
|
cid_2 = get_channel_id_from_response(expected_response_1)
|
||||||
cid_2_bytes = cid_2.to_bytes(2, "big")
|
# cid_2_bytes = cid_2.to_bytes(2, "big")
|
||||||
channel = thp_main._CHANNELS[cid_2]
|
channel = thp_main._CHANNELS[cid_2]
|
||||||
channel.iface = self.interface
|
channel.iface = self.interface
|
||||||
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
|
# flake8: noqa: F403,F405
|
||||||
from common import * # isort:skip
|
from common import * # isort:skip
|
||||||
|
|
||||||
from typing import Any, Awaitable
|
from typing import Any, Awaitable
|
||||||
|
|
||||||
|
|
||||||
if utils.USE_THP:
|
if utils.USE_THP:
|
||||||
import thp_common
|
import thp_common
|
||||||
from mock_wire_interface import MockHID
|
from mock_wire_interface import MockHID
|
||||||
from trezor.wire.thp import writer
|
from trezor.wire.thp import ENCRYPTED, PacketHeader, writer
|
||||||
from trezor.wire.thp import ENCRYPTED, PacketHeader
|
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(utils.USE_THP, "only needed for THP")
|
@unittest.skipUnless(utils.USE_THP, "only needed for THP")
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: F403,F405
|
||||||
from common import * # isort:skip
|
from common import * # isort:skip
|
||||||
import ustruct
|
import ustruct
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
@ -11,9 +12,8 @@ from trezor.wire.protocol_common import Message
|
|||||||
if utils.USE_THP:
|
if utils.USE_THP:
|
||||||
import thp_common
|
import thp_common
|
||||||
import trezor.wire.thp
|
import trezor.wire.thp
|
||||||
from trezor.wire.thp import thp_main
|
|
||||||
from trezor.wire.thp import alternating_bit_protocol as ABP
|
from trezor.wire.thp import alternating_bit_protocol as ABP
|
||||||
from trezor.wire.thp import checksum
|
from trezor.wire.thp import checksum, thp_main
|
||||||
from trezor.wire.thp.checksum import CHECKSUM_LENGTH
|
from trezor.wire.thp.checksum import CHECKSUM_LENGTH
|
||||||
from trezor.wire.thp.writer import PACKET_LENGTH
|
from trezor.wire.thp.writer import PACKET_LENGTH
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# flake8: noqa: F403,F405
|
||||||
from trezor import utils
|
from trezor import utils
|
||||||
from trezor.wire.thp import ChannelState
|
from trezor.wire.thp import ChannelState
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user