chore(tests): change model to internal model, change model identifiers

[no changelog]
grdddj/internal_model_tests
grdddj 10 months ago
parent 1d6c0abeb6
commit dd53198751

@ -34,7 +34,7 @@ def cli() -> None:
def cosi_warn(client: "TrezorClient") -> None:
if client.features.model == "1" and client.version < (1, 11, 2):
if client.features.internal_model == "T1B1" and client.version < (1, 11, 2):
click.echo("WARNING: CoSi signing on your Trezor is insecure.")
click.echo("Please update your Trezor to firmware version 1.11.2 or newer.")
click.echo("If you used CoSi in the past, consider rotating your keys.")

@ -274,7 +274,7 @@ def sd_protect(
off - Remove SD card secret protection.
refresh - Replace the current SD card secret with a new one.
"""
if client.features.model == "1":
if client.features.internal_model == "T1B1":
raise click.ClickException("Trezor One does not support SD card protection.")
return device.sd_protect(client, operation)

@ -265,7 +265,7 @@ def homescreen(client: "TrezorClient", filename: str) -> str:
if not path.exists() or not path.is_file():
raise click.ClickException("Cannot open file")
if client.features.model == "1":
if client.features.internal_model == "T1B1":
img = image_to_t1(path)
else:
if client.features.homescreen_format == messages.HomescreenFormat.Jpeg:

@ -334,7 +334,7 @@ def get_session(obj: TrezorConnection) -> str:
obj.session_id = None
with obj.client_context() as client:
if client.features.model == "1" and client.version < (1, 9, 0):
if client.features.internal_model == "T1B1" and client.version < (1, 9, 0):
raise click.ClickException(
"Upgrade your firmware to enable session support."
)

@ -452,7 +452,7 @@ class DebugLink:
def reset_debug_events(self) -> None:
# Only supported on TT and above certain version
if self.model in ("T", "R") and not self.legacy_debug:
if self.internal_model in ("T2T1", "T2B1") and not self.legacy_debug:
return self._call(messages.DebugLinkResetDebugEvents())
return None
@ -685,7 +685,7 @@ class DebugLink:
) -> None:
self.screenshot_recording_dir = directory
# Different recording logic between core and legacy
if self.model in ("T", "R"):
if self.internal_model in ("T2T1", "T2B1"):
self._call(
messages.DebugLinkRecordScreen(
target_directory=directory, refresh_index=refresh_index
@ -699,7 +699,7 @@ class DebugLink:
def stop_recording(self) -> None:
self.screenshot_recording_dir = None
# Different recording logic between TT and T1
if self.model in ("T", "R"):
if self.internal_model in ("T2T1", "T2B1"):
self._call(messages.DebugLinkRecordScreen(target_directory=None))
else:
self.t1_take_screenshots = False
@ -726,7 +726,7 @@ class DebugLink:
TT handles them differently, see debuglink.start_recording.
"""
if self.model == "1" and self.t1_take_screenshots:
if self.internal_model == "T1B1" and self.t1_take_screenshots:
self.save_screenshot_for_t1()
def save_screenshot_for_t1(self) -> None:
@ -1102,7 +1102,7 @@ class TrezorClientDebugLink(TrezorClient):
expected response is only evaluated if the first field is True.
This is useful for differentiating sequences between Trezor models:
>>> trezor_one = client.features.model == "1"
>>> trezor_one = client.features.internal_model == "T1B1"
>>> client.set_expected_responses([
>>> messages.ButtonRequest(code=ConfirmOutput),
>>> (trezor_one, messages.ButtonRequest(code=ConfirmOutput)),

@ -119,7 +119,7 @@ def recover(
dry_run: bool = False,
u2f_counter: Optional[int] = None,
) -> "MessageType":
if client.features.model == "1" and input_callback is None:
if client.features.internal_model == "T1B1" and input_callback is None:
raise RuntimeError("Input callback required for Trezor One")
if word_count not in (12, 18, 24):
@ -180,7 +180,7 @@ def reset(
)
if strength is None:
if client.features.model == "1":
if client.features.internal_model == "T1B1":
strength = 256
else:
strength = 128

@ -105,7 +105,8 @@ class Transport:
client = TrezorClient(transport, ui=SilentUI())
self.model = (
trezorlib.models.by_name(client.features.model) or trezorlib.models.TREZOR_T
trezorlib.models.by_internal_name(client.features.internal_model)
or trezorlib.models.TREZOR_T
)
client.end_session()

@ -43,9 +43,9 @@ def get_char_category(char: str) -> PassphraseCategory:
def go_next(debug: "DebugLink", wait: bool = False) -> "LayoutContent" | None:
if debug.model == "T":
if debug.internal_model == "T2T1":
return debug.click(buttons.OK, wait=wait) # type: ignore
elif debug.model == "R":
elif debug.internal_model == "T2B1":
return debug.press_right(wait=wait) # type: ignore
else:
raise RuntimeError("Unknown model")
@ -54,9 +54,9 @@ def go_next(debug: "DebugLink", wait: bool = False) -> "LayoutContent" | None:
def go_back(
debug: "DebugLink", wait: bool = False, r_middle: bool = False
) -> "LayoutContent" | None:
if debug.model == "T":
if debug.internal_model == "T2T1":
return debug.click(buttons.CANCEL, wait=wait) # type: ignore
elif debug.model == "R":
elif debug.internal_model == "T2B1":
if r_middle:
return debug.press_middle(wait=wait) # type: ignore
else:

@ -10,13 +10,13 @@ if TYPE_CHECKING:
def enter_word(
debug: "DebugLink", word: str, is_slip39: bool = False
) -> "LayoutContent":
if debug.model == "T":
if debug.internal_model == "T2T1":
typed_word = word[:4]
for coords in buttons.type_word(typed_word, is_slip39=is_slip39):
debug.click(coords)
return debug.click(buttons.CONFIRM_WORD, wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
letter_index = 0
layout = debug.read_layout()
@ -40,10 +40,10 @@ def enter_word(
def confirm_recovery(debug: "DebugLink") -> None:
layout = debug.wait_layout()
if debug.model == "T":
if debug.internal_model == "T2T1":
assert layout.title().startswith(("RECOVER WALLET", "BACKUP CHECK"))
debug.click(buttons.OK, wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
assert layout.title() == "RECOVER WALLET"
debug.press_right(wait=True)
debug.press_right()
@ -54,7 +54,7 @@ def select_number_of_words(
) -> None:
if wait:
debug.wait_layout()
if debug.model == "T":
if debug.internal_model == "T2T1":
assert "number of words" in debug.read_layout().text_content()
assert debug.read_layout().title() in (
"BACKUP CHECK",
@ -69,7 +69,7 @@ def select_number_of_words(
) # raises if num of words is invalid
coords = buttons.grid34(index % 3, index // 3)
layout = debug.click(coords, wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
assert "number of words" in debug.read_layout().text_content()
layout = debug.press_right(wait=True)
@ -93,7 +93,7 @@ def select_number_of_words(
def enter_share(
debug: "DebugLink", share: str, is_first: bool = True
) -> "LayoutContent":
if debug.model == "T":
if debug.internal_model == "T2T1":
layout = debug.click(buttons.OK, wait=True)
assert layout.main_component() == "MnemonicKeyboard"
@ -101,7 +101,7 @@ def enter_share(
layout = enter_word(debug, word, is_slip39=True)
return layout
elif debug.model == "R":
elif debug.internal_model == "T2B1":
assert "RECOVER WALLET" in debug.wait_layout().title()
layout = debug.press_right(wait=True)
if is_first:
@ -131,10 +131,10 @@ def enter_shares(debug: "DebugLink", shares: list[str]) -> None:
def enter_seed(debug: "DebugLink", seed_words: list[str]) -> None:
assert "Enter" in debug.read_layout().text_content()
if debug.model == "T":
if debug.internal_model == "T2T1":
layout = debug.click(buttons.OK, wait=True)
assert layout.main_component() == "MnemonicKeyboard"
elif debug.model == "R":
elif debug.internal_model == "T2B1":
layout = debug.press_right(wait=True)
assert "RECOVER WALLET" in layout.title()
debug.press_right()

@ -13,9 +13,9 @@ if TYPE_CHECKING:
def confirm_new_wallet(debug: "DebugLink") -> None:
layout = debug.wait_layout()
assert layout.title().startswith("CREATE WALLET")
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click(buttons.OK, wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
debug.press_right(wait=True)
debug.press_right(wait=True)
@ -41,9 +41,9 @@ def confirm_read(debug: "DebugLink", title: str, middle_r: bool = False) -> None
else:
assert title.upper() in layout.title()
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click(buttons.OK, wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
if layout.page_count() > 1:
debug.press_right(wait=True)
if middle_r:
@ -53,12 +53,12 @@ def confirm_read(debug: "DebugLink", title: str, middle_r: bool = False) -> None
def set_selection(debug: "DebugLink", button: tuple[int, int], diff: int) -> None:
if debug.model == "T":
if debug.internal_model == "T2T1":
assert "NumberInputDialog" in debug.read_layout().all_components()
for _ in range(diff):
debug.click(button)
debug.click(buttons.OK, wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
layout = debug.read_layout()
if layout.title() in ("NUMBER OF SHARES", "THRESHOLD"):
# Special info screens
@ -79,14 +79,14 @@ def read_words(
words: list[str] = []
layout = debug.read_layout()
if debug.model == "T":
if debug.internal_model == "T2T1":
if backup_type == messages.BackupType.Slip39_Advanced:
assert layout.title().startswith("GROUP")
elif backup_type == messages.BackupType.Slip39_Basic:
assert layout.title().startswith("RECOVERY SHARE #")
else:
assert layout.title() == "RECOVERY SEED"
elif debug.model == "R":
elif debug.internal_model == "T2B1":
if backup_type == messages.BackupType.Slip39_Advanced:
assert "SHARE" in layout.title()
elif backup_type == messages.BackupType.Slip39_Basic:
@ -102,14 +102,14 @@ def read_words(
words.extend(layout.seed_words())
layout = debug.swipe_up(wait=True)
assert layout is not None
if debug.model == "T":
if debug.internal_model == "T2T1":
words.extend(layout.seed_words())
# There is hold-to-confirm button
if do_htc:
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click_hold(buttons.OK, hold_ms=1500)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
debug.press_right_htc(1200)
else:
# It would take a very long time to test 16-of-16 with doing 1500 ms HTC after
@ -121,7 +121,7 @@ def read_words(
def confirm_words(debug: "DebugLink", words: list[str]) -> None:
layout = debug.wait_layout()
if debug.model == "T":
if debug.internal_model == "T2T1":
assert "Select word" in layout.text_content()
for _ in range(3):
# "Select word 3 of 20"
@ -134,7 +134,7 @@ def confirm_words(debug: "DebugLink", words: list[str]) -> None:
wanted_word = words[word_pos - 1].lower()
button_pos = btn_texts.index(wanted_word)
layout = debug.click(buttons.RESET_WORD_CHECK[button_pos], wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
assert "Select the correct word" in layout.text_content()
layout = debug.press_right(wait=True)
for _ in range(3):

@ -100,11 +100,11 @@ def test_autolock_interrupts_signing(device_handler: "BackgroundDeviceHandler"):
in debug.wait_layout().text_content().replace(" ", "")
)
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click(buttons.OK, wait=True)
layout = debug.click(buttons.OK, wait=True)
assert "Total amount: 0.0039 BTC" in layout.text_content()
elif debug.model == "R":
elif debug.internal_model == "T2B1":
debug.press_right(wait=True)
layout = debug.press_right(wait=True)
assert "Total amount: 0.0039 BTC" in layout.text_content()
@ -145,11 +145,11 @@ def test_autolock_does_not_interrupt_signing(device_handler: "BackgroundDeviceHa
in debug.wait_layout().text_content().replace(" ", "")
)
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click(buttons.OK, wait=True)
layout = debug.click(buttons.OK, wait=True)
assert "Total amount: 0.0039 BTC" in layout.text_content()
elif debug.model == "R":
elif debug.internal_model == "T2B1":
debug.press_right(wait=True)
layout = debug.press_right(wait=True)
assert "Total amount: 0.0039 BTC" in layout.text_content()
@ -162,9 +162,9 @@ def test_autolock_does_not_interrupt_signing(device_handler: "BackgroundDeviceHa
with device_handler.client:
device_handler.client.set_filter(messages.TxAck, sleepy_filter)
# confirm transaction
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click(buttons.OK)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
debug.press_middle()
signatures, tx = device_handler.result()
@ -184,17 +184,17 @@ def test_autolock_passphrase_keyboard(device_handler: "BackgroundDeviceHandler")
assert "PassphraseKeyboard" in debug.wait_layout().all_components()
if debug.model == "R":
if debug.internal_model == "T2B1":
# Going into the selected character category
debug.press_middle()
# enter passphrase - slowly
# keep clicking for long enough to trigger the autolock if it incorrectly ignored key presses
for _ in range(math.ceil(11 / 1.5)):
if debug.model == "T":
if debug.internal_model == "T2T1":
# click at "j"
debug.click(CENTER_BUTTON)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
# just go right
# NOTE: because of passphrase randomization it would be a pain to input
# a specific passphrase, which is not in scope for this test.
@ -202,9 +202,9 @@ def test_autolock_passphrase_keyboard(device_handler: "BackgroundDeviceHandler")
time.sleep(1.5)
# Send the passphrase to the client (TT has it clicked already, TR needs to input it)
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click(buttons.OK, wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
debug.input("j" * 8, wait=True)
# address corresponding to "jjjjjjjj" passphrase
@ -221,16 +221,16 @@ def test_autolock_interrupts_passphrase(device_handler: "BackgroundDeviceHandler
assert "PassphraseKeyboard" in debug.wait_layout().all_components()
if debug.model == "R":
if debug.internal_model == "T2B1":
# Going into the selected character category
debug.press_middle()
# enter passphrase - slowly
# autolock must activate even if we pressed some buttons
for _ in range(math.ceil(6 / 1.5)):
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click(CENTER_BUTTON)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
debug.press_middle()
time.sleep(1.5)
@ -261,7 +261,7 @@ def test_dryrun_locks_at_number_of_words(device_handler: "BackgroundDeviceHandle
layout = unlock_dry_run(debug)
assert "number of words" in layout.text_content()
if debug.model == "R":
if debug.internal_model == "T2B1":
debug.press_right(wait=True)
# wait for autolock to trigger
@ -294,10 +294,10 @@ def test_dryrun_locks_at_word_entry(device_handler: "BackgroundDeviceHandler"):
# select 20 words
recovery.select_number_of_words(debug, 20)
if debug.model == "T":
if debug.internal_model == "T2T1":
layout = debug.click(buttons.OK, wait=True)
assert layout.main_component() == "MnemonicKeyboard"
elif debug.model == "R":
elif debug.internal_model == "T2B1":
layout = debug.press_right(wait=True)
assert "MnemonicKeyboard" in layout.all_components()
@ -320,7 +320,7 @@ def test_dryrun_enter_word_slowly(device_handler: "BackgroundDeviceHandler"):
# select 20 words
recovery.select_number_of_words(debug, 20)
if debug.model == "T":
if debug.internal_model == "T2T1":
layout = debug.click(buttons.OK, wait=True)
assert layout.main_component() == "MnemonicKeyboard"
@ -331,7 +331,7 @@ def test_dryrun_enter_word_slowly(device_handler: "BackgroundDeviceHandler"):
layout = debug.click(buttons.CONFIRM_WORD, wait=True)
# should not have locked, even though we took 9 seconds to type each letter
assert layout.main_component() == "MnemonicKeyboard"
elif debug.model == "R":
elif debug.internal_model == "T2B1":
layout = debug.press_right(wait=True)
assert "MnemonicKeyboard" in layout.all_components()

@ -32,11 +32,11 @@ PIN4 = "1234"
def test_hold_to_lock(device_handler: "BackgroundDeviceHandler"):
debug = device_handler.debuglink()
short_duration = 1000 if debug.model == "T" else 500
lock_duration = 3500 if debug.model == "T" else 1200
short_duration = 1000 if debug.internal_model == "T2T1" else 500
lock_duration = 3500 if debug.internal_model == "T2T1" else 1200
def hold(duration: int, wait: bool = True) -> None:
if debug.model == "R":
if debug.internal_model == "T2B1":
debug.press_right_htc(hold_ms=duration)
else:
debug.input(x=13, y=37, hold_ms=duration, wait=wait)
@ -63,7 +63,7 @@ def test_hold_to_lock(device_handler: "BackgroundDeviceHandler"):
assert device_handler.features().unlocked is False
# unlock by touching
if debug.model == "R":
if debug.internal_model == "T2B1":
# Doing a short HTC to simulate a click
debug.press_right_htc(hold_ms=100)
layout = debug.wait_layout()

@ -85,9 +85,9 @@ def prepare(
# Set new PIN
device_handler.run(device.change_pin) # type: ignore
assert "Turn on" in debug.wait_layout().text_content()
if debug.model == "T":
if debug.internal_model == "T2T1":
go_next(debug)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
go_next(debug, wait=True)
go_next(debug, wait=True)
go_next(debug, wait=True)
@ -106,7 +106,7 @@ def prepare(
_input_see_confirm(debug, old_pin)
assert "Turn on" in debug.wait_layout().text_content()
go_next(debug, wait=True)
if debug.model == "R":
if debug.internal_model == "T2B1":
go_next(debug, wait=True)
go_next(debug, wait=True)
go_next(debug, wait=True)
@ -130,13 +130,13 @@ def _input_pin(debug: "DebugLink", pin: str, check: bool = False) -> None:
if check:
before = debug.read_layout().pin()
if debug.model == "T":
if debug.internal_model == "T2T1":
digits_order = debug.read_layout().tt_pin_digits_order()
for digit in pin:
digit_index = digits_order.index(digit)
coords = buttons.pin_passphrase_index(digit_index)
debug.click(coords, wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
for digit in pin:
navigate_to_action_and_press(debug, digit, TR_PIN_ACTIONS)
@ -147,9 +147,9 @@ def _input_pin(debug: "DebugLink", pin: str, check: bool = False) -> None:
def _see_pin(debug: "DebugLink") -> None:
"""Navigate to "SHOW" and press it"""
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click(buttons.TOP_ROW, wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
navigate_to_action_and_press(debug, "SHOW", TR_PIN_ACTIONS)
@ -159,9 +159,9 @@ def _delete_pin(debug: "DebugLink", digits_to_delete: int, check: bool = True) -
before = debug.read_layout().pin()
for _ in range(digits_to_delete):
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click(buttons.pin_passphrase_grid(9), wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
navigate_to_action_and_press(debug, "DELETE", TR_PIN_ACTIONS)
if check:
@ -178,9 +178,9 @@ def _cancel_pin(debug: "DebugLink") -> None:
def _confirm_pin(debug: "DebugLink") -> None:
"""Navigate to "ENTER" and press it"""
if debug.model == "T":
if debug.internal_model == "T2T1":
debug.click(buttons.pin_passphrase_grid(11), wait=True)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
navigate_to_action_and_press(debug, "ENTER", TR_PIN_ACTIONS)
@ -193,7 +193,7 @@ def _input_see_confirm(debug: "DebugLink", pin: str) -> None:
def _enter_two_times(debug: "DebugLink", pin1: str, pin2: str) -> None:
_input_see_confirm(debug, pin1)
if debug.model == "R":
if debug.internal_model == "T2B1":
# Please re-enter
go_next(debug, wait=True)
@ -265,10 +265,10 @@ def test_pin_setup(device_handler: "BackgroundDeviceHandler"):
def test_pin_setup_mismatch(device_handler: "BackgroundDeviceHandler"):
with PIN_CANCELLED, prepare(device_handler, Situation.PIN_SETUP) as debug:
_enter_two_times(debug, "1", "2")
if debug.model == "T":
if debug.internal_model == "T2T1":
go_next(debug)
_cancel_pin(debug)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
debug.press_middle()
debug.press_no()

@ -160,12 +160,12 @@ def read_and_confirm_mnemonic(
debug: "DebugLink", choose_wrong: bool = False
) -> Generator[None, "ButtonRequest", Optional[str]]:
# TODO: these are very similar, reuse some code
if debug.model == "T":
if debug.internal_model == "T2T1":
mnemonic = yield from read_and_confirm_mnemonic_tt(debug, choose_wrong)
elif debug.model == "R":
elif debug.internal_model == "T2B1":
mnemonic = yield from read_and_confirm_mnemonic_tr(debug, choose_wrong)
else:
raise ValueError(f"Unknown model: {debug.model}")
raise ValueError(f"Unknown model: {debug.internal_model}")
return mnemonic

@ -188,11 +188,20 @@ def client(
@pytest.mark.experimental
"""
if request.node.get_closest_marker("skip_t2") and _raw_client.features.model == "T":
if (
request.node.get_closest_marker("skip_t2")
and _raw_client.features.internal_model == "T2T1"
):
pytest.skip("Test excluded on Trezor T")
if request.node.get_closest_marker("skip_t1") and _raw_client.features.model == "1":
if (
request.node.get_closest_marker("skip_t1")
and _raw_client.features.internal_model == "T1B1"
):
pytest.skip("Test excluded on Trezor 1")
if request.node.get_closest_marker("skip_tr") and _raw_client.features.model == "R":
if (
request.node.get_closest_marker("skip_tr")
and _raw_client.features.internal_model == "T2B1"
):
pytest.skip("Test excluded on Trezor R")
sd_marker = request.node.get_closest_marker("sd_card")

@ -449,7 +449,7 @@ def test_sign_tx_spend(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
messages.ButtonRequest(code=B.Other),
@ -524,7 +524,7 @@ def test_sign_tx_migration(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
messages.ButtonRequest(code=B.Other),

@ -72,7 +72,7 @@ def test_send_bch_change(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -125,7 +125,7 @@ def test_send_bch_nochange(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -184,7 +184,7 @@ def test_send_bch_oldaddr(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -255,7 +255,7 @@ def test_attack_change_input(client: Client):
return msg
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_filter(messages.TxAck, attack_processor)
client.set_expected_responses(
[
@ -331,7 +331,7 @@ def test_send_bch_multisig_wrongchange(client: Client):
amount=23_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -400,7 +400,7 @@ def test_send_bch_multisig_change(client: Client):
amount=24_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -502,7 +502,7 @@ def test_send_bch_external_presigned(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),

@ -71,7 +71,7 @@ def test_send_bitcoin_gold_change(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -125,7 +125,7 @@ def test_send_bitcoin_gold_nochange(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -195,7 +195,7 @@ def test_attack_change_input(client: Client):
return msg
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_filter(messages.TxAck, attack_processor)
client.set_expected_responses(
[
@ -257,7 +257,7 @@ def test_send_btg_multisig_change(client: Client):
amount=1_252_382_934 - 24_000 - 1_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -351,7 +351,7 @@ def test_send_p2sh(client: Client):
amount=1_252_382_934 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -405,7 +405,7 @@ def test_send_p2sh_witness_change(client: Client):
amount=1_252_382_934 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -466,7 +466,7 @@ def test_send_multisig_1(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -584,7 +584,7 @@ def test_send_btg_external_presigned(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),

@ -57,7 +57,7 @@ def test_send_dash(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -105,7 +105,7 @@ def test_send_dash_dip2_input(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),

@ -72,7 +72,7 @@ def test_send_decred(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -194,7 +194,7 @@ def test_spend_from_stake_generation_and_revocation_decred(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -276,7 +276,7 @@ def test_send_decred_change(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -383,7 +383,7 @@ def test_decred_multisig_change(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),

@ -61,7 +61,7 @@ def test_one_one_fee_sapling(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -126,7 +126,7 @@ def test_one_one_rewards_claim(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),

@ -82,7 +82,7 @@ def test_2_of_3(client: Client):
)
# Expected responses are the same for both two signings
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
expected_responses = [
request_input(0),
request_output(0),
@ -233,7 +233,7 @@ def test_missing_pubkey(client: Client):
with pytest.raises(TrezorFailure) as exc:
btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=TX_API)
if client.features.model == "1":
if client.features.internal_model == "T1B1":
assert exc.value.message.endswith("Failed to derive scriptPubKey")
else:
assert exc.value.message.endswith("Pubkey not found in multisig script")

@ -145,7 +145,7 @@ def _responses(
change: int = 0,
foreign: bool = False,
):
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
resp = [
request_input(0),
request_input(1),

@ -63,7 +63,7 @@ def test_opreturn(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),

@ -319,7 +319,7 @@ def test_signmessage_pagination(client: Client, message: str):
# We cannot differentiate between a newline and space in the message read from Trezor.
# TODO: do the check also for model R
if client.features.model == "T":
if client.features.internal_model == "T2T1":
expected_message = (
("Confirm message: " + message).replace("\n", "").replace(" ", "")
)

@ -127,7 +127,7 @@ def test_one_one_fee(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -181,7 +181,7 @@ def test_testnet_one_two_fee(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -232,7 +232,7 @@ def test_testnet_fee_high_warning(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -285,7 +285,7 @@ def test_one_two_fee(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -347,7 +347,7 @@ def test_one_three_fee(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -418,7 +418,7 @@ def test_two_two(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -563,7 +563,7 @@ def test_lots_of_change(client: Client):
request_change_outputs = [request_output(i + 1) for i in range(cnt)]
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -615,7 +615,7 @@ def test_fee_high_warning(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -704,7 +704,7 @@ def test_not_enough_funds(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -735,7 +735,7 @@ def test_p2sh(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -823,7 +823,7 @@ def test_attack_change_outputs(client: Client):
# Test if the transaction can be signed normally
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -991,7 +991,7 @@ def test_attack_change_input_address(client: Client):
# Now run the attack, must trigger the exception
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_filter(messages.TxAck, attack_processor)
client.set_expected_responses(
[
@ -1043,7 +1043,7 @@ def test_spend_coinbase(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -1102,7 +1102,7 @@ def test_two_changes(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -1162,7 +1162,7 @@ def test_change_on_main_chain_allowed(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -1427,7 +1427,7 @@ def test_lock_time(client: Client, lock_time: int, sequence: int):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),

@ -216,7 +216,7 @@ def test_p2wpkh_in_p2sh_presigned(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -268,7 +268,7 @@ def test_p2wpkh_in_p2sh_presigned(client: Client):
# Test corrupted script hash in scriptsig.
inp1.script_sig[10] ^= 1
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -401,7 +401,7 @@ def test_p2wsh_external_presigned(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -447,7 +447,7 @@ def test_p2wsh_external_presigned(client: Client):
# Test corrupted signature in witness.
inp2.witness[10] ^= 1
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -513,7 +513,7 @@ def test_p2tr_external_presigned(client: Client):
script_type=messages.OutputScriptType.PAYTOTAPROOT,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -546,7 +546,7 @@ def test_p2tr_external_presigned(client: Client):
# Test corrupted signature in witness.
inp2.witness[10] ^= 1
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -616,8 +616,8 @@ def test_p2wpkh_with_proof(client: Client):
)
with client:
t1 = client.features.model == "1"
tt = client.features.model == "T"
t1 = client.features.internal_model == "T1B1"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -710,8 +710,8 @@ def test_p2tr_with_proof(client: Client):
)
with client:
t1 = client.features.model == "1"
tt = client.features.model == "T"
t1 = client.features.internal_model == "T1B1"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),

@ -177,7 +177,7 @@ def test_payment_request(client: Client, payment_request_params):
def test_payment_request_details(client: Client):
if client.features.model == "R":
if client.features.internal_model == "T2B1":
pytest.skip("Details not implemented on TR")
# Test that payment request details are shown when requested.

@ -64,7 +64,7 @@ def hash_tx(data: bytes) -> bytes:
def _check_error_message(value: bytes, model: str, message: str):
# T1 has several possible errors
if model == "1" and len(value) > 32:
if model == "T1B1" and len(value) > 32:
assert message.endswith("bytes overflow")
else:
assert message.endswith("Provided prev_hash is invalid.")
@ -92,7 +92,7 @@ def test_invalid_prev_hash(client: Client, prev_hash):
with pytest.raises(TrezorFailure) as e:
btc.sign_tx(client, "Testnet", [inp1], [out1], prev_txes={})
_check_error_message(prev_hash, client.features.model, e.value.message)
_check_error_message(prev_hash, client.features.internal_model, e.value.message)
@with_bad_prevhashes
@ -134,7 +134,7 @@ def test_invalid_prev_hash_attack(client: Client, prev_hash):
# check that injection was performed
assert counter == 0
_check_error_message(prev_hash, client.features.model, e.value.message)
_check_error_message(prev_hash, client.features.internal_model, e.value.message)
@with_bad_prevhashes
@ -165,4 +165,4 @@ def test_invalid_prev_hash_in_prevtx(client: Client, prev_hash):
with pytest.raises(TrezorFailure) as e:
btc.sign_tx(client, "Bitcoin", [inp0], [out1], prev_txes={tx_hash: prev_tx})
_check_error_message(prev_hash, client.features.model, e.value.message)
_check_error_message(prev_hash, client.features.internal_model, e.value.message)

@ -115,7 +115,7 @@ def test_p2pkh_fee_bump(client: Client):
orig_index=1,
)
new_model = client.features.model in ("T", "R")
new_model = client.features.internal_model in ("T2T1", "T2B1")
with client:
client.set_expected_responses(
@ -600,7 +600,7 @@ def test_p2wpkh_in_p2sh_fee_bump_from_external(client: Client):
orig_index=0,
)
tr = client.features.model == "R"
tr = client.features.internal_model == "T2B1"
with client:
client.set_expected_responses(
[

@ -65,7 +65,7 @@ def test_send_p2sh(client: Client):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -119,7 +119,7 @@ def test_send_p2sh_change(client: Client):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -175,7 +175,7 @@ def test_testnet_segwit_big_amount(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -233,7 +233,7 @@ def test_send_multisig_1(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
expected_responses = [
request_input(0),
request_output(0),
@ -301,7 +301,7 @@ def test_attack_change_input_address(client: Client):
# Test if the transaction can be signed normally.
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -381,7 +381,7 @@ def test_attack_mixed_inputs(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
expected_responses = [
request_input(0),
request_input(1),
@ -409,7 +409,7 @@ def test_attack_mixed_inputs(client: Client):
request_finished(),
]
if client.features.model == "1":
if client.features.internal_model == "T1B1":
# T1 asks for first input for witness again
expected_responses.insert(-2, request_input(0))
@ -428,7 +428,7 @@ def test_attack_mixed_inputs(client: Client):
# In Phase 1 make the user confirm a lower value of the segwit input.
inp2.amount = FAKE_AMOUNT
if client.features.model == "1":
if client.features.internal_model == "T1B1":
# T1 fails as soon as it encounters the fake amount.
expected_responses = (
expected_responses[:4] + expected_responses[5:15] + [messages.Failure()]

@ -81,7 +81,7 @@ def test_send_p2sh(client: Client):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -137,7 +137,7 @@ def test_send_p2sh_change(client: Client):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -191,7 +191,7 @@ def test_send_native(client: Client):
amount=100_000 - 40_000 - 10_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -279,7 +279,7 @@ def test_send_native_change(client: Client):
amount=100_000 - 40_000 - 10_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -347,7 +347,7 @@ def test_send_both(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -431,7 +431,7 @@ def test_send_multisig_1(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
expected_responses = [
request_input(0),
request_output(0),
@ -509,7 +509,7 @@ def test_send_multisig_2(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
expected_responses = [
request_input(0),
request_output(0),
@ -594,7 +594,7 @@ def test_send_multisig_3_change(client: Client):
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
)
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
expected_responses = [
request_input(0),
request_output(0),
@ -681,7 +681,7 @@ def test_send_multisig_4_change(client: Client):
script_type=messages.OutputScriptType.PAYTOWITNESS,
)
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
expected_responses = [
request_input(0),
request_output(0),
@ -783,7 +783,7 @@ def test_multisig_mismatch_inputs_single(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),

@ -78,7 +78,7 @@ def test_send_p2tr(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -133,7 +133,7 @@ def test_send_two_with_change(client: Client):
amount=6_800 + 13_000 - 200 - 15_000,
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -223,7 +223,7 @@ def test_send_mixed(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
# process inputs
@ -293,7 +293,7 @@ def test_send_mixed(client: Client):
request_input(0),
request_input(1),
request_input(2),
(client.features.model == "1", request_input(3)),
(client.features.internal_model == "T1B1", request_input(3)),
request_finished(),
]
)
@ -355,7 +355,7 @@ def test_attack_script_type(client: Client):
return msg
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_filter(messages.TxAck, attack_processor)
client.set_expected_responses(
[

@ -106,7 +106,7 @@ def test_one_one_fee_sapling(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -260,7 +260,7 @@ def test_external_presigned(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),

@ -33,10 +33,10 @@ def show_details_input_flow(client: Client):
yield
client.debug.wait_layout()
# Clicking for model T, pressing right for model R
if client.features.model == "T":
if client.features.internal_model == "T2T1":
SHOW_ALL_BUTTON_POSITION = (143, 167)
client.debug.click(SHOW_ALL_BUTTON_POSITION)
elif client.features.model == "R":
elif client.features.internal_model == "T2B1":
client.debug.press_yes()
# reset ui flow to continue "automatically"
client.ui.input_flow = None

@ -176,8 +176,8 @@ def test_data_streaming(client: Client):
checked in vectorized function above.
"""
with client:
t1 = client.features.model == "1"
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
t1 = client.features.internal_model == "T1B1"
client.set_expected_responses(
[
messages.ButtonRequest(code=messages.ButtonRequestType.SignTx),
@ -386,8 +386,15 @@ def input_flow_data_scroll_down(client: Client, cancel: bool = False):
return InputFlowEthereumSignTxDataScrollDown(client, cancel).get()
<<<<<<< HEAD
def input_flow_data_go_back(client: Client, cancel: bool = False):
return InputFlowEthereumSignTxDataGoBack(client, cancel).get()
=======
def input_flow_go_back(client: Client, cancel: bool = False):
if client.features.internal_model == "T2B1":
pytest.skip("Go back not supported for model R")
return InputFlowEthereumSignTxGoBack(client, cancel).get()
>>>>>>> 4ca6fa320 (chore(tests): change model to internal model, change model identifiers)
HEXDATA = "0123456789abcd000023456789abcd010003456789abcd020000456789abcd030000056789abcd040000006789abcd050000000789abcd060000000089abcd070000000009abcd080000000000abcd090000000001abcd0a0000000011abcd0b0000000111abcd0c0000001111abcd0d0000011111abcd0e0000111111abcd0f0000000002abcd100000000022abcd110000000222abcd120000002222abcd130000022222abcd140000222222abcd15"

@ -31,7 +31,7 @@ pytestmark = [
# assertion data from T1
def test_nem_signtx_simple(client: Client):
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
with client:
client.set_expected_responses(
[
@ -82,7 +82,7 @@ def test_nem_signtx_simple(client: Client):
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_nem_signtx_encrypted_payload(client: Client):
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
# Confirm transfer and network fee

@ -60,7 +60,7 @@ def do_recover_core(client: Client, mnemonic: list[str], mismatch: bool = False)
def do_recover(client: Client, mnemonic: list[str], mismatch: bool = False):
if client.features.model == "1":
if client.features.internal_model == "T1B1":
return do_recover_legacy(client, mnemonic)
else:
return do_recover_core(client, mnemonic, mismatch)

@ -167,7 +167,7 @@ def test_failed_pin(client: Client):
ret = client.call_raw(messages.ButtonAck())
# Re-enter PIN for TR
if client.debug.model == "R":
if client.debug.internal_model == "T2B1":
assert isinstance(ret, messages.ButtonRequest)
client.debug.press_yes()
ret = client.call_raw(messages.ButtonAck())

@ -32,7 +32,7 @@ pytestmark = pytest.mark.setup_client(pin=PIN4)
def pin_request(client: Client):
return (
messages.PinMatrixRequest
if client.features.model == "1"
if client.features.internal_model == "T1B1"
else messages.ButtonRequest
)

@ -27,7 +27,7 @@ PIN = "1234"
def _assert_busy(client: Client, should_be_busy: bool, screen: str = "Homescreen"):
assert client.features.busy is should_be_busy
if client.debug.model in ("T", "R"):
if client.debug.internal_model in ("T2T1", "T2B1"):
if should_be_busy:
assert "CoinJoinProgress" in client.debug.read_layout().all_components()
else:

@ -93,7 +93,7 @@ def test_cancel_on_paginated(client: Client):
# In TR, confirm message is no longer paginated by default,
# user needs to click info button
if client.debug.model == "R":
if client.debug.internal_model == "T2B1":
client._raw_write(m.ButtonAck())
client.debug.press_right()
resp = client._raw_read()

@ -6,9 +6,9 @@ from trezorlib import firmware
from trezorlib.debuglink import TrezorClientDebugLink as Client
FIRMWARE_LENGTHS = {
"1": 7 * 128 * 1024 + 64 * 1024,
"T": 13 * 128 * 1024,
"R": 13 * 128 * 1024,
"T1B1": 7 * 128 * 1024 + 64 * 1024,
"T2T1": 13 * 128 * 1024,
"T2B1": 13 * 128 * 1024,
}
@ -16,7 +16,7 @@ def test_firmware_hash_emu(client: Client) -> None:
if client.features.fw_vendor != "EMULATOR":
pytest.skip("Only for emulator")
data = b"\xff" * FIRMWARE_LENGTHS[client.features.model]
data = b"\xff" * FIRMWARE_LENGTHS[client.features.internal_model]
expected_hash = blake2s(data).digest()
hash = firmware.get_hash(client, None)
@ -34,7 +34,7 @@ def test_firmware_hash_hw(client: Client) -> None:
# TODO get firmware image from outside the environment, check for actual result
challenge = b"Hello Trezor"
empty_data = b"\xff" * FIRMWARE_LENGTHS[client.features.model]
empty_data = b"\xff" * FIRMWARE_LENGTHS[client.features.internal_model]
empty_hash = blake2s(empty_data).digest()
empty_hash_challenge = blake2s(empty_data, key=challenge).digest()

@ -50,7 +50,7 @@ TR_HOMESCREEN = b"TOIG\x80\x00@\x00\x0c\x04\x00\x00\xa5RY\x96\xdc0\x08\xe4\x06\x
def _set_expected_responses(client: Client):
client.use_pin_sequence([PIN4])
if client.features.model == "1":
if client.features.internal_model == "T1B1":
client.set_expected_responses(EXPECTED_RESPONSES_PIN_T1)
else:
client.set_expected_responses(EXPECTED_RESPONSES_PIN_TT)
@ -356,7 +356,7 @@ def test_safety_checks(client: Client):
client.set_expected_responses([messages.Failure])
get_bad_address()
if client.features.model != "1":
if client.features.internal_model != "T1B1":
with client:
client.set_expected_responses(EXPECTED_RESPONSES_NOPIN)
device.apply_settings(

@ -59,7 +59,7 @@ def test_backup_bip39(client: Client):
"click_info", [True, False], ids=["click_info", "no_click_info"]
)
def test_backup_slip39_basic(client: Client, click_info: bool):
if click_info and client.features.model == "R":
if click_info and client.features.internal_model == "T2B1":
pytest.skip("click_info not implemented on TR")
assert client.features.needs_backup is True
@ -87,7 +87,7 @@ def test_backup_slip39_basic(client: Client, click_info: bool):
"click_info", [True, False], ids=["click_info", "no_click_info"]
)
def test_backup_slip39_advanced(client: Client, click_info: bool):
if click_info and client.features.model == "R":
if click_info and client.features.internal_model == "T2B1":
pytest.skip("click_info not implemented on TR")
assert client.features.needs_backup is True

@ -38,7 +38,7 @@ def _check_wipe_code(client: Client, pin: str, wipe_code: str):
# Try to change the PIN to the current wipe code value. The operation should fail.
with client, pytest.raises(TrezorFailure):
client.use_pin_sequence([pin, wipe_code, wipe_code])
br_amount = 5 if client.debug.model == "T" else 6
br_amount = 5 if client.debug.internal_model == "T2T1" else 6
client.set_expected_responses(
[messages.ButtonRequest()] * br_amount
+ [messages.Failure(code=messages.FailureType.PinInvalid)]
@ -63,7 +63,7 @@ def test_set_remove_wipe_code(client: Client):
assert client.features.wipe_code_protection is False
with client:
br_amount = 5 if client.debug.model == "T" else 6
br_amount = 5 if client.debug.internal_model == "T2T1" else 6
client.set_expected_responses(
[messages.ButtonRequest()] * br_amount
+ [messages.Success, messages.Features]
@ -77,7 +77,7 @@ def test_set_remove_wipe_code(client: Client):
# Test change wipe code.
with client:
br_amount = 5 if client.debug.model == "T" else 6
br_amount = 5 if client.debug.internal_model == "T2T1" else 6
client.set_expected_responses(
[messages.ButtonRequest()] * br_amount
+ [messages.Success, messages.Features]
@ -118,7 +118,7 @@ def test_set_wipe_code_to_pin(client: Client):
_ensure_unlocked(client, PIN4)
with client:
br_amount = 7 if client.debug.model == "T" else 8
br_amount = 7 if client.debug.internal_model == "T2T1" else 8
client.set_expected_responses(
[messages.ButtonRequest()] * br_amount
+ [messages.Success, messages.Features]
@ -134,7 +134,7 @@ def test_set_wipe_code_to_pin(client: Client):
def test_set_pin_to_wipe_code(client: Client):
# Set wipe code.
with client:
br_amount = 4 if client.debug.model == "T" else 5
br_amount = 4 if client.debug.internal_model == "T2T1" else 5
client.set_expected_responses(
[messages.ButtonRequest()] * br_amount
+ [messages.Success, messages.Features]
@ -144,7 +144,7 @@ def test_set_pin_to_wipe_code(client: Client):
# Try to set the PIN to the current wipe code value.
with client, pytest.raises(TrezorFailure):
br_amount = 4 if client.debug.model == "T" else 6
br_amount = 4 if client.debug.internal_model == "T2T1" else 6
client.set_expected_responses(
[messages.ButtonRequest()] * br_amount
+ [messages.Failure(code=messages.FailureType.PinInvalid)]

@ -62,7 +62,7 @@ def test_set_pin(client: Client):
# Let's set new PIN
with client:
br_amount = 4 if client.debug.model == "T" else 6
br_amount = 4 if client.debug.internal_model == "T2T1" else 6
client.use_pin_sequence([PIN_MAX, PIN_MAX])
client.set_expected_responses(
[messages.ButtonRequest] * br_amount + [messages.Success, messages.Features]
@ -84,7 +84,7 @@ def test_change_pin(client: Client):
# Let's change PIN
with client:
client.use_pin_sequence([PIN4, PIN_MAX, PIN_MAX])
br_amount = 5 if client.debug.model == "T" else 6
br_amount = 5 if client.debug.internal_model == "T2T1" else 6
client.set_expected_responses(
[messages.ButtonRequest] * br_amount + [messages.Success, messages.Features]
)

@ -59,7 +59,7 @@ def test_load_device_2(client: Client):
state = client.debug.state()
assert state.mnemonic_secret == MNEMONIC12.encode()
if client.features.model == "1":
if client.features.internal_model == "T1B1":
# we do not send PIN in DebugLinkState in Core
assert state.pin == "1234"
assert state.passphrase_protection is True

@ -42,7 +42,7 @@ def test_correct_pin(client: Client):
with client:
client.use_pin_sequence([PIN4])
# Expected responses differ between T1 and TT
is_t1 = client.features.model == "1"
is_t1 = client.features.internal_model == "T1B1"
client.set_expected_responses(
[
(is_t1, messages.PinMatrixRequest),

@ -44,7 +44,7 @@ pytestmark = pytest.mark.setup_client(pin=PIN4, passphrase=True)
def _pin_request(client: Client):
"""Get appropriate PIN request for each model"""
if client.features.model == "1":
if client.features.internal_model == "T1B1":
return messages.PinMatrixRequest
else:
return messages.ButtonRequest(code=B.PinEntry)
@ -140,7 +140,7 @@ def test_change_pin_t2(client: Client):
messages.ButtonRequest,
_pin_request(client),
_pin_request(client),
(client.debug.model == "R", messages.ButtonRequest),
(client.debug.internal_model == "T2B1", messages.ButtonRequest),
_pin_request(client),
messages.ButtonRequest,
messages.Success,
@ -362,7 +362,7 @@ def test_signtx(client: Client):
_assert_protection(client)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.use_pin_sequence([PIN4])
client.set_expected_responses(
[

@ -32,7 +32,7 @@ PIN4 = "1234"
@pytest.mark.setup_client(pin=PIN4, passphrase="")
def test_clear_session(client: Client):
is_trezor1 = client.features.model == "1"
is_trezor1 = client.features.internal_model == "T1B1"
init_responses = [
messages.PinMatrixRequest if is_trezor1 else messages.ButtonRequest,
messages.PassphraseRequest,

@ -396,13 +396,13 @@ def test_hide_passphrase_from_host(client: Client):
def input_flow():
yield
layout = client.debug.wait_layout()
if client.debug.model == "T":
if client.debug.internal_model == "T2T1":
assert (
"Passphrase provided by host will be used but will not be displayed due to the device settings."
in layout.text_content()
)
client.debug.press_yes()
elif client.debug.model == "R":
elif client.debug.internal_model == "T2B1":
layout = client.debug.wait_layout()
assert "will not be displayed" in layout.text_content()
client.debug.press_right()

@ -95,7 +95,7 @@ def test_spend_v4_input(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -144,7 +144,7 @@ def test_send_to_multisig(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -192,7 +192,7 @@ def test_spend_v5_input(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -246,7 +246,7 @@ def test_one_two(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -305,7 +305,7 @@ def test_unified_address(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -370,7 +370,7 @@ def test_external_presigned(client: Client):
)
with client:
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
client.set_expected_responses(
[
request_input(0),
@ -483,7 +483,7 @@ def test_spend_multisig(client: Client):
)
# Expected responses are the same for both two signings
tt = client.features.model == "T"
tt = client.features.internal_model == "T2T1"
expected_responses = [
request_input(0),
request_output(0),

@ -51,7 +51,7 @@ class InputFlowBase:
self.ETH = EthereumFlow(self.client)
def model(self) -> str | None:
return self.client.features.model
return self.client.features.internal_model
def get(self) -> Callable[[], BRGeneratorType]:
self.client.watch_layout(True)
@ -59,9 +59,9 @@ class InputFlowBase:
# There could be one common input flow for all models
if hasattr(self, "input_flow_common"):
return getattr(self, "input_flow_common")
elif self.model() == "T":
elif self.model() == "T2T1":
return self.input_flow_tt
elif self.model() == "R":
elif self.model() == "T2B1":
return self.input_flow_tr
else:
raise ValueError("Unknown model")
@ -97,7 +97,7 @@ class InputFlowSetupDevicePINWIpeCode(InputFlowBase):
yield # do you want to set/change the wipe code?
self.debug.press_yes()
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
yield from swipe_if_necessary(self.debug) # wipe code info
self.debug.press_yes()
@ -126,7 +126,7 @@ class InputFlowNewCodeMismatch(InputFlowBase):
yield # do you want to set/change the pin/wipe code?
self.debug.press_yes()
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
yield from swipe_if_necessary(self.debug) # code info
self.debug.press_yes()
@ -671,9 +671,9 @@ class InputFlowEIP712ShowMore(InputFlowBase):
def _confirm_show_more(self) -> None:
"""Model-specific, either clicks a screen or presses a button."""
if self.model() == "T":
if self.model() == "T2T1":
self.debug.click(self.SHOW_MORE)
elif self.model() == "R":
elif self.model() == "T2B1":
self.debug.press_right()
def input_flow_common(self) -> BRGeneratorType:
@ -1260,7 +1260,7 @@ class InputFlowSlip39AdvancedRecoveryAbort(InputFlowBase):
def input_flow_common(self) -> BRGeneratorType:
yield from self.REC.confirm_recovery()
if self.debug.model == "T":
if self.debug.internal_model == "T2T1":
yield from self.REC.input_number_of_words(20)
yield from self.REC.abort_recovery(True)
@ -1273,7 +1273,7 @@ class InputFlowSlip39AdvancedRecoveryNoAbort(InputFlowBase):
def input_flow_common(self) -> BRGeneratorType:
yield from self.REC.confirm_recovery()
if self.debug.model == "T":
if self.debug.internal_model == "T2T1":
yield from self.REC.input_number_of_words(self.word_count)
yield from self.REC.abort_recovery(False)
else:
@ -1372,7 +1372,7 @@ class InputFlowSlip39BasicRecoveryAbort(InputFlowBase):
def input_flow_common(self) -> BRGeneratorType:
yield from self.REC.confirm_recovery()
if self.debug.model == "T":
if self.debug.internal_model == "T2T1":
yield from self.REC.input_number_of_words(20)
yield from self.REC.abort_recovery(True)
@ -1386,7 +1386,7 @@ class InputFlowSlip39BasicRecoveryNoAbort(InputFlowBase):
def input_flow_common(self) -> BRGeneratorType:
yield from self.REC.confirm_recovery()
if self.debug.model == "T":
if self.debug.internal_model == "T2T1":
yield from self.REC.input_number_of_words(self.word_count)
yield from self.REC.abort_recovery(False)
else:
@ -1487,7 +1487,7 @@ class InputFlowResetSkipBackup(InputFlowBase):
yield from self.BAK.confirm_new_wallet()
yield # Skip Backup
assert "New wallet created" in self.text_content()
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
self.debug.press_right()
self.debug.press_no()
yield # Confirm skip backup

@ -17,7 +17,7 @@ class PinFlow:
yield # Enter PIN
assert "PinKeyboard" in self.debug.wait_layout().all_components()
self.debug.input(pin)
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
yield # Reenter PIN
assert "re-enter PIN" in self.debug.wait_layout().text_content()
self.debug.press_yes()
@ -37,7 +37,7 @@ class BackupFlow:
def confirm_new_wallet(self) -> BRGeneratorType:
yield
assert "By continuing you agree" in self.debug.wait_layout().text_content()
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
self.debug.press_right()
self.debug.press_yes()
@ -50,7 +50,7 @@ class RecoveryFlow:
def confirm_recovery(self) -> BRGeneratorType:
yield
assert "By continuing you agree" in self.debug.wait_layout().text_content()
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
self.debug.press_right()
self.debug.press_yes()
@ -60,13 +60,13 @@ class RecoveryFlow:
self.debug.press_yes()
def setup_slip39_recovery(self, num_words: int) -> BRGeneratorType:
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
yield from self.tr_recovery_homescreen()
yield from self.input_number_of_words(num_words)
yield from self.enter_any_share()
def setup_bip39_recovery(self, num_words: int) -> BRGeneratorType:
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
yield from self.tr_recovery_homescreen()
yield from self.input_number_of_words(num_words)
yield from self.enter_your_backup()
@ -80,7 +80,7 @@ class RecoveryFlow:
yield
assert "Enter your backup" in self.debug.wait_layout().text_content()
if (
self.debug.model == "R"
self.debug.internal_model == "T2B1"
and "BACKUP CHECK" not in self.debug.wait_layout().title()
):
# Normal recovery has extra info (not dry run)
@ -92,7 +92,7 @@ class RecoveryFlow:
yield
assert "Enter any share" in self.debug.wait_layout().text_content()
if (
self.debug.model == "R"
self.debug.internal_model == "T2B1"
and "BACKUP CHECK" not in self.debug.wait_layout().title()
):
# Normal recovery has extra info (not dry run)
@ -102,7 +102,7 @@ class RecoveryFlow:
def abort_recovery(self, confirm: bool) -> BRGeneratorType:
yield
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
assert "number of words" in self.debug.wait_layout().text_content()
else:
assert "Enter any share" in self.debug.wait_layout().text_content()
@ -110,7 +110,7 @@ class RecoveryFlow:
yield
assert "cancel the recovery" in self.debug.wait_layout().text_content()
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
self.debug.press_right()
if confirm:
self.debug.press_yes()
@ -120,7 +120,7 @@ class RecoveryFlow:
def input_number_of_words(self, num_words: int) -> BRGeneratorType:
br = yield
assert br.code == B.MnemonicWordCount
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
assert "NUMBER OF WORDS" in self.debug.wait_layout().title()
else:
assert "number of words" in self.debug.wait_layout().text_content()
@ -214,7 +214,7 @@ class RecoveryFlow:
assert br.code == B.MnemonicInput
assert "MnemonicKeyboard" in self.debug.wait_layout().all_components()
for index, word in enumerate(mnemonic):
if self.debug.model == "R":
if self.debug.internal_model == "T2B1":
assert f"WORD {index + 1}" in self.debug.wait_layout().title()
else:
assert (
@ -235,7 +235,7 @@ class RecoveryFlow:
if index < len(shares) - 1:
if has_groups:
yield from self.success_share_group_entered()
if self.debug.model == "T" and click_info:
if self.debug.internal_model == "T2T1" and click_info:
yield from self.tt_click_info()
yield from self.success_more_shares_needed()

@ -225,7 +225,7 @@ class TestCase:
def build(cls, client: Client, request: pytest.FixtureRequest) -> Self:
name, group = _get_test_name_and_group(request.node.nodeid)
return cls(
model=f"T{client.features.model}",
model=client.features.internal_model or "",
name=name,
group=group,
)

Loading…
Cancel
Save