1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 21:22:10 +00:00

fix(tests): Safe 3 model name

[no changelog]
This commit is contained in:
Martin Milata 2023-10-12 00:31:02 +02:00
parent fca82273cf
commit 0c5836605f
39 changed files with 163 additions and 156 deletions

View File

@ -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.model in ("T", "Safe 3") and not self.legacy_debug:
return self._call(messages.DebugLinkResetDebugEvents())
return None
@ -703,7 +703,7 @@ class DebugLink:
) -> None:
self.screenshot_recording_dir = directory
# Different recording logic between core and legacy
if self.model in ("T", "R"):
if self.model in ("T", "Safe 3"):
self._call(
messages.DebugLinkRecordScreen(
target_directory=directory, refresh_index=refresh_index
@ -717,7 +717,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.model in ("T", "Safe 3"):
self._call(messages.DebugLinkRecordScreen(target_directory=None))
else:
self.t1_take_screenshots = False

View File

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

View File

@ -16,7 +16,7 @@ def enter_word(
debug.click(coords)
return debug.click(buttons.CONFIRM_WORD, wait=True)
elif debug.model == "R":
elif debug.model == "Safe 3":
letter_index = 0
layout = debug.read_layout()
@ -43,7 +43,7 @@ def confirm_recovery(debug: "DebugLink") -> None:
if debug.model == "T":
assert layout.title().startswith(("RECOVER WALLET", "BACKUP CHECK"))
debug.click(buttons.OK, wait=True)
elif debug.model == "R":
elif debug.model == "Safe 3":
assert layout.title() == "RECOVER WALLET"
debug.press_right(wait=True)
debug.press_right()
@ -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.model == "Safe 3":
assert "number of words" in debug.read_layout().text_content()
layout = debug.press_right(wait=True)
@ -101,7 +101,7 @@ def enter_share(
layout = enter_word(debug, word, is_slip39=True)
return layout
elif debug.model == "R":
elif debug.model == "Safe 3":
assert "RECOVER WALLET" in debug.wait_layout().title()
layout = debug.press_right(wait=True)
if is_first:
@ -134,7 +134,7 @@ def enter_seed(debug: "DebugLink", seed_words: list[str]) -> None:
if debug.model == "T":
layout = debug.click(buttons.OK, wait=True)
assert layout.main_component() == "MnemonicKeyboard"
elif debug.model == "R":
elif debug.model == "Safe 3":
layout = debug.press_right(wait=True)
assert "RECOVER WALLET" in layout.title()
debug.press_right()

View File

@ -15,7 +15,7 @@ def confirm_new_wallet(debug: "DebugLink") -> None:
assert layout.title().startswith("CREATE WALLET")
if debug.model == "T":
debug.click(buttons.OK, wait=True)
elif debug.model == "R":
elif debug.model == "Safe 3":
debug.press_right(wait=True)
debug.press_right(wait=True)
@ -43,7 +43,7 @@ def confirm_read(debug: "DebugLink", title: str, middle_r: bool = False) -> None
if debug.model == "T":
debug.click(buttons.OK, wait=True)
elif debug.model == "R":
elif debug.model == "Safe 3":
if layout.page_count() > 1:
debug.press_right(wait=True)
if middle_r:
@ -58,7 +58,7 @@ def set_selection(debug: "DebugLink", button: tuple[int, int], diff: int) -> Non
for _ in range(diff):
debug.click(button)
debug.click(buttons.OK, wait=True)
elif debug.model == "R":
elif debug.model == "Safe 3":
layout = debug.read_layout()
if layout.title() in ("NUMBER OF SHARES", "THRESHOLD"):
# Special info screens
@ -86,7 +86,7 @@ def read_words(
assert layout.title().startswith("RECOVERY SHARE #")
else:
assert layout.title() == "RECOVERY SEED"
elif debug.model == "R":
elif debug.model == "Safe 3":
if backup_type == messages.BackupType.Slip39_Advanced:
assert "SHARE" in layout.title()
elif backup_type == messages.BackupType.Slip39_Basic:
@ -109,7 +109,7 @@ def read_words(
if do_htc:
if debug.model == "T":
debug.click_hold(buttons.OK, hold_ms=1500)
elif debug.model == "R":
elif debug.model == "Safe 3":
debug.press_right_htc(1200)
else:
# It would take a very long time to test 16-of-16 with doing 1500 ms HTC after
@ -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.model == "Safe 3":
assert "Select the correct word" in layout.text_content()
layout = debug.press_right(wait=True)
for _ in range(3):

View File

@ -104,7 +104,7 @@ def test_autolock_interrupts_signing(device_handler: "BackgroundDeviceHandler"):
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.model == "Safe 3":
debug.press_right(wait=True)
layout = debug.press_right(wait=True)
assert "Total amount: 0.0039 BTC" in layout.text_content()
@ -149,7 +149,7 @@ def test_autolock_does_not_interrupt_signing(device_handler: "BackgroundDeviceHa
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.model == "Safe 3":
debug.press_right(wait=True)
layout = debug.press_right(wait=True)
assert "Total amount: 0.0039 BTC" in layout.text_content()
@ -164,7 +164,7 @@ def test_autolock_does_not_interrupt_signing(device_handler: "BackgroundDeviceHa
# confirm transaction
if debug.model == "T":
debug.click(buttons.OK)
elif debug.model == "R":
elif debug.model == "Safe 3":
debug.press_middle()
signatures, tx = device_handler.result()
@ -184,7 +184,7 @@ def test_autolock_passphrase_keyboard(device_handler: "BackgroundDeviceHandler")
assert "PassphraseKeyboard" in debug.wait_layout().all_components()
if debug.model == "R":
if debug.model == "Safe 3":
# Going into the selected character category
debug.press_middle()
@ -194,7 +194,7 @@ def test_autolock_passphrase_keyboard(device_handler: "BackgroundDeviceHandler")
if debug.model == "T":
# click at "j"
debug.click(CENTER_BUTTON)
elif debug.model == "R":
elif debug.model == "Safe 3":
# 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.
@ -204,7 +204,7 @@ def test_autolock_passphrase_keyboard(device_handler: "BackgroundDeviceHandler")
# Send the passphrase to the client (TT has it clicked already, TR needs to input it)
if debug.model == "T":
debug.click(buttons.OK, wait=True)
elif debug.model == "R":
elif debug.model == "Safe 3":
debug.input("j" * 8, wait=True)
# address corresponding to "jjjjjjjj" passphrase
@ -221,7 +221,7 @@ def test_autolock_interrupts_passphrase(device_handler: "BackgroundDeviceHandler
assert "PassphraseKeyboard" in debug.wait_layout().all_components()
if debug.model == "R":
if debug.model == "Safe 3":
# Going into the selected character category
debug.press_middle()
@ -230,7 +230,7 @@ def test_autolock_interrupts_passphrase(device_handler: "BackgroundDeviceHandler
for _ in range(math.ceil(6 / 1.5)):
if debug.model == "T":
debug.click(CENTER_BUTTON)
elif debug.model == "R":
elif debug.model == "Safe 3":
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.model == "Safe 3":
debug.press_right(wait=True)
# wait for autolock to trigger
@ -297,7 +297,7 @@ def test_dryrun_locks_at_word_entry(device_handler: "BackgroundDeviceHandler"):
if debug.model == "T":
layout = debug.click(buttons.OK, wait=True)
assert layout.main_component() == "MnemonicKeyboard"
elif debug.model == "R":
elif debug.model == "Safe 3":
layout = debug.press_right(wait=True)
assert "MnemonicKeyboard" in layout.all_components()
@ -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.model == "Safe 3":
layout = debug.press_right(wait=True)
assert "MnemonicKeyboard" in layout.all_components()

View File

@ -36,7 +36,7 @@ def test_hold_to_lock(device_handler: "BackgroundDeviceHandler"):
lock_duration = 3500 if debug.model == "T" else 1200
def hold(duration: int, wait: bool = True) -> None:
if debug.model == "R":
if debug.model == "Safe 3":
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.model == "Safe 3":
# Doing a short HTC to simulate a click
debug.press_right_htc(hold_ms=100)
layout = debug.wait_layout()

View File

@ -87,7 +87,7 @@ def prepare(
assert "Turn on" in debug.wait_layout().text_content()
if debug.model == "T":
go_next(debug)
elif debug.model == "R":
elif debug.model == "Safe 3":
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.model == "Safe 3":
go_next(debug, wait=True)
go_next(debug, wait=True)
go_next(debug, wait=True)
@ -136,7 +136,7 @@ def _input_pin(debug: "DebugLink", pin: str, check: bool = False) -> None:
digit_index = digits_order.index(digit)
coords = buttons.pin_passphrase_index(digit_index)
debug.click(coords, wait=True)
elif debug.model == "R":
elif debug.model == "Safe 3":
for digit in pin:
navigate_to_action_and_press(debug, digit, TR_PIN_ACTIONS)
@ -149,7 +149,7 @@ def _see_pin(debug: "DebugLink") -> None:
"""Navigate to "SHOW" and press it"""
if debug.model == "T":
debug.click(buttons.TOP_ROW, wait=True)
elif debug.model == "R":
elif debug.model == "Safe 3":
navigate_to_action_and_press(debug, "SHOW", TR_PIN_ACTIONS)
@ -161,7 +161,7 @@ def _delete_pin(debug: "DebugLink", digits_to_delete: int, check: bool = True) -
for _ in range(digits_to_delete):
if debug.model == "T":
debug.click(buttons.pin_passphrase_grid(9), wait=True)
elif debug.model == "R":
elif debug.model == "Safe 3":
navigate_to_action_and_press(debug, "DELETE", TR_PIN_ACTIONS)
if check:
@ -173,7 +173,7 @@ def _delete_all(debug: "DebugLink", check: bool = True) -> None:
"""Navigate to "DELETE" and hold it until all digits are deleted"""
if debug.model == "T":
debug.click_hold(buttons.pin_passphrase_grid(9), hold_ms=1500)
elif debug.model == "R":
elif debug.model == "Safe 3":
navigate_to_action_and_press(debug, "DELETE", TR_PIN_ACTIONS, hold_ms=1000)
if check:
@ -192,7 +192,7 @@ def _confirm_pin(debug: "DebugLink") -> None:
"""Navigate to "ENTER" and press it"""
if debug.model == "T":
debug.click(buttons.pin_passphrase_grid(11), wait=True)
elif debug.model == "R":
elif debug.model == "Safe 3":
navigate_to_action_and_press(debug, "ENTER", TR_PIN_ACTIONS)
@ -205,7 +205,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.model == "Safe 3":
# Please re-enter
go_next(debug, wait=True)
@ -298,7 +298,7 @@ def test_pin_setup_mismatch(device_handler: "BackgroundDeviceHandler"):
if debug.model == "T":
go_next(debug)
_cancel_pin(debug)
elif debug.model == "R":
elif debug.model == "Safe 3":
debug.press_middle()
debug.press_no()

View File

@ -162,7 +162,7 @@ def read_and_confirm_mnemonic(
# TODO: these are very similar, reuse some code
if debug.model == "T":
mnemonic = yield from read_and_confirm_mnemonic_tt(debug, choose_wrong)
elif debug.model == "R":
elif debug.model == "Safe 3":
mnemonic = yield from read_and_confirm_mnemonic_tr(debug, choose_wrong)
else:
raise ValueError(f"Unknown model: {debug.model}")

View File

@ -192,7 +192,10 @@ def client(
pytest.skip("Test excluded on Trezor T")
if request.node.get_closest_marker("skip_t1") and _raw_client.features.model == "1":
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.model == "Safe 3"
):
pytest.skip("Test excluded on Trezor R")
sd_marker = request.node.get_closest_marker("sd_card")

View File

@ -453,7 +453,7 @@ def test_sign_tx_spend(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
messages.ButtonRequest(code=B.Other),
@ -528,7 +528,7 @@ def test_sign_tx_migration(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
messages.ButtonRequest(code=B.Other),

View File

@ -72,7 +72,7 @@ def test_send_bch_change(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -255,7 +255,7 @@ def test_attack_change_input(client: Client):
return msg
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -400,7 +400,7 @@ def test_send_bch_multisig_change(client: Client):
amount=24_000,
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),

View File

@ -71,7 +71,7 @@ def test_send_bitcoin_gold_change(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -195,7 +195,7 @@ def test_attack_change_input(client: Client):
return msg
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -466,7 +466,7 @@ def test_send_multisig_1(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),

View File

@ -57,7 +57,7 @@ def test_send_dash(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),

View File

@ -72,7 +72,7 @@ def test_send_decred(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -194,7 +194,7 @@ def test_spend_from_stake_generation_and_revocation_decred(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -276,7 +276,7 @@ def test_send_decred_change(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -383,7 +383,7 @@ def test_decred_multisig_change(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),

View File

@ -61,7 +61,7 @@ def test_one_one_fee_sapling(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -126,7 +126,7 @@ def test_one_one_rewards_claim(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),

View File

@ -83,7 +83,7 @@ def test_2_of_3(client: Client, chunkify: bool):
)
# Expected responses are the same for both two signings
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
expected_responses = [
request_input(0),
request_output(0),

View File

@ -145,7 +145,7 @@ def _responses(
change: int = 0,
foreign: bool = False,
):
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
resp = [
request_input(0),
request_input(1),

View File

@ -63,7 +63,7 @@ def test_opreturn(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),

View File

@ -127,7 +127,7 @@ def test_one_one_fee(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -181,7 +181,7 @@ def test_testnet_one_two_fee(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -232,7 +232,7 @@ def test_testnet_fee_high_warning(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -285,7 +285,7 @@ def test_one_two_fee(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -348,7 +348,7 @@ def test_one_three_fee(client: Client, chunkify: bool):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -420,7 +420,7 @@ def test_two_two(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -565,7 +565,7 @@ def test_lots_of_change(client: Client):
request_change_outputs = [request_output(i + 1) for i in range(cnt)]
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -617,7 +617,7 @@ def test_fee_high_warning(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -706,7 +706,7 @@ def test_not_enough_funds(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -737,7 +737,7 @@ def test_p2sh(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -825,7 +825,7 @@ def test_attack_change_outputs(client: Client):
# Test if the transaction can be signed normally
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -993,7 +993,7 @@ def test_attack_change_input_address(client: Client):
# Now run the attack, must trigger the exception
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_filter(messages.TxAck, attack_processor)
client.set_expected_responses(
[
@ -1045,7 +1045,7 @@ def test_spend_coinbase(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -1104,7 +1104,7 @@ def test_two_changes(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -1164,7 +1164,7 @@ def test_change_on_main_chain_allowed(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -1429,7 +1429,7 @@ def test_lock_time(client: Client, lock_time: int, sequence: int):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),

View File

@ -216,7 +216,7 @@ def test_p2wpkh_in_p2sh_presigned(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -401,7 +401,7 @@ def test_p2wsh_external_presigned(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -617,7 +617,7 @@ def test_p2wpkh_with_proof(client: Client):
with client:
is_t1 = client.features.model == "1"
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -711,7 +711,7 @@ def test_p2tr_with_proof(client: Client):
with client:
is_t1 = client.features.model == "1"
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),

View File

@ -184,7 +184,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.model == "Safe 3":
pytest.skip("Details not implemented on TR")
# Test that payment request details are shown when requested.

View File

@ -115,7 +115,7 @@ def test_p2pkh_fee_bump(client: Client):
orig_index=1,
)
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
with client:
client.set_expected_responses(
@ -600,7 +600,7 @@ def test_p2wpkh_in_p2sh_fee_bump_from_external(client: Client):
orig_index=0,
)
is_tr = client.features.model == "R"
is_tr = client.features.model == "Safe 3"
with client:
client.set_expected_responses(
[

View File

@ -66,7 +66,7 @@ def test_send_p2sh(client: Client, chunkify: bool):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -125,7 +125,7 @@ def test_send_p2sh_change(client: Client):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -181,7 +181,7 @@ def test_testnet_segwit_big_amount(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -239,7 +239,7 @@ def test_send_multisig_1(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
expected_responses = [
request_input(0),
request_output(0),
@ -307,7 +307,7 @@ def test_attack_change_input_address(client: Client):
# Test if the transaction can be signed normally.
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -387,7 +387,7 @@ def test_attack_mixed_inputs(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
expected_responses = [
request_input(0),
request_input(1),

View File

@ -81,7 +81,7 @@ def test_send_p2sh(client: Client):
amount=123_456_789 - 11_000 - 12_300_000,
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -347,8 +347,8 @@ def test_send_both(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -433,7 +433,7 @@ def test_send_multisig_1(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
expected_responses = [
request_input(0),
request_output(0),
@ -511,7 +511,7 @@ def test_send_multisig_2(client: Client):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
expected_responses = [
request_input(0),
request_output(0),
@ -596,7 +596,7 @@ def test_send_multisig_3_change(client: Client):
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
)
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
expected_responses = [
request_input(0),
request_output(0),
@ -683,7 +683,7 @@ def test_send_multisig_4_change(client: Client):
script_type=messages.OutputScriptType.PAYTOWITNESS,
)
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
expected_responses = [
request_input(0),
request_output(0),
@ -785,7 +785,7 @@ def test_multisig_mismatch_inputs_single(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),

View File

@ -79,7 +79,7 @@ def test_send_p2tr(client: Client, chunkify: bool):
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -134,7 +134,7 @@ def test_send_two_with_change(client: Client):
amount=6_800 + 13_000 - 200 - 15_000,
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -224,8 +224,8 @@ def test_send_mixed(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
# process inputs
@ -358,8 +358,8 @@ def test_attack_script_type(client: Client):
return msg
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
is_core = client.features.model in ("T", "Safe 3")
client.set_filter(messages.TxAck, attack_processor)
client.set_expected_responses(
[

View File

@ -106,7 +106,7 @@ def test_one_one_fee_sapling(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -260,7 +260,7 @@ def test_external_presigned(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),

View File

@ -36,7 +36,7 @@ def show_details_input_flow(client: Client):
if client.features.model == "T":
SHOW_ALL_BUTTON_POSITION = (143, 167)
client.debug.click(SHOW_ALL_BUTTON_POSITION)
elif client.features.model == "R":
elif client.features.model == "Safe 3":
client.debug.press_yes()
# reset ui flow to continue "automatically"
client.ui.input_flow = None

View File

@ -33,7 +33,7 @@ pytestmark = [
# assertion data from T1
@pytest.mark.parametrize("chunkify", (True, False))
def test_nem_signtx_simple(client: Client, chunkify: bool):
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
with client:
client.set_expected_responses(
[
@ -85,7 +85,7 @@ def test_nem_signtx_simple(client: Client, chunkify: bool):
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_nem_signtx_encrypted_payload(client: Client):
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
# Confirm transfer and network fee

View File

@ -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.model == "Safe 3":
assert isinstance(ret, messages.ButtonRequest)
client.debug.press_yes()
ret = client.call_raw(messages.ButtonAck())

View File

@ -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.model in ("T", "Safe 3"):
if should_be_busy:
assert "CoinJoinProgress" in client.debug.read_layout().all_components()
else:

View File

@ -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.model == "Safe 3":
client._raw_write(m.ButtonAck())
client.debug.press_right()
resp = client._raw_read()

View File

@ -8,7 +8,7 @@ from trezorlib.debuglink import TrezorClientDebugLink as Client
FIRMWARE_LENGTHS = {
"1": 7 * 128 * 1024 + 64 * 1024,
"T": 13 * 128 * 1024,
"R": 13 * 128 * 1024,
"Safe 3": 13 * 128 * 1024,
}

View File

@ -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.model == "Safe 3":
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.model == "Safe 3":
pytest.skip("click_info not implemented on TR")
assert client.features.needs_backup is True

View File

@ -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.model == "Safe 3", messages.ButtonRequest),
_pin_request(client),
messages.ButtonRequest,
messages.Success,
@ -362,7 +362,7 @@ def test_signtx(client: Client):
_assert_protection(client)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.use_pin_sequence([PIN4])
client.set_expected_responses(
[

View File

@ -402,7 +402,7 @@ def test_hide_passphrase_from_host(client: Client):
in layout.text_content()
)
client.debug.press_yes()
elif client.debug.model == "R":
elif client.debug.model == "Safe 3":
layout = client.debug.wait_layout()
assert "will not be displayed" in layout.text_content()
client.debug.press_right()

View File

@ -95,7 +95,7 @@ def test_spend_v4_input(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -144,7 +144,7 @@ def test_send_to_multisig(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -192,7 +192,7 @@ def test_spend_v5_input(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -246,7 +246,7 @@ def test_one_two(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -305,7 +305,7 @@ def test_unified_address(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
client.set_expected_responses(
[
request_input(0),
@ -370,7 +370,7 @@ def test_external_presigned(client: Client):
)
with client:
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
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
is_core = client.features.model in ("T", "R")
is_core = client.features.model in ("T", "Safe 3")
expected_responses = [
request_input(0),
request_output(0),

View File

@ -61,7 +61,7 @@ class InputFlowBase:
return getattr(self, "input_flow_common")
elif self.model() == "T":
return self.input_flow_tt
elif self.model() == "R":
elif self.model() == "Safe 3":
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.model == "Safe 3":
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.model == "Safe 3":
yield from swipe_if_necessary(self.debug) # code info
self.debug.press_yes()
@ -751,7 +751,7 @@ class InputFlowEIP712ShowMore(InputFlowBase):
"""Model-specific, either clicks a screen or presses a button."""
if self.model() == "T":
self.debug.click(self.SHOW_MORE)
elif self.model() == "R":
elif self.model() == "Safe 3":
self.debug.press_right()
def input_flow_common(self) -> BRGeneratorType:
@ -1565,7 +1565,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.model == "Safe 3":
self.debug.press_right()
self.debug.press_no()
yield # Confirm skip backup

View File

@ -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.model == "Safe 3":
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.model == "Safe 3":
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.model == "Safe 3":
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.model == "Safe 3":
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.model == "Safe 3":
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.model == "Safe 3"
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.model == "Safe 3"
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.model == "Safe 3":
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.model == "Safe 3":
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.model == "Safe 3":
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.model == "Safe 3":
assert f"WORD {index + 1}" in self.debug.wait_layout().title()
else:
assert (

View File

@ -223,9 +223,13 @@ class TestCase:
@classmethod
def build(cls, client: Client, request: pytest.FixtureRequest) -> Self:
model = client.features.model
# FIXME
if model == "Safe 3":
model = "R"
name, group = _get_test_name_and_group(request.node.nodeid)
return cls(
model=f"T{client.features.model}",
model=f"T{model}",
name=name,
group=group,
)