mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-26 08:29:26 +00:00
WIP - make device tests work with UI changes
This commit is contained in:
parent
8f1962f3bb
commit
0558e6f1d5
@ -1316,7 +1316,7 @@ async def confirm_pin_action(
|
|||||||
br_type: str,
|
br_type: str,
|
||||||
title: str,
|
title: str,
|
||||||
action: str | None,
|
action: str | None,
|
||||||
description: str | None,
|
description: str | None = "Do you really want to",
|
||||||
br_code: ButtonRequestType = ButtonRequestType.Other,
|
br_code: ButtonRequestType = ButtonRequestType.Other,
|
||||||
) -> None:
|
) -> None:
|
||||||
return await confirm_action(
|
return await confirm_action(
|
||||||
|
@ -226,7 +226,7 @@ def test_invalid_seed_core(client: Client):
|
|||||||
yield
|
yield
|
||||||
layout = client.debug.wait_layout()
|
layout = client.debug.wait_layout()
|
||||||
assert "WORD ENTERING" in layout.text
|
assert "WORD ENTERING" in layout.text
|
||||||
client.debug.press_right()
|
client.debug.press_yes()
|
||||||
|
|
||||||
yield
|
yield
|
||||||
for _ in range(12):
|
for _ in range(12):
|
||||||
|
@ -44,7 +44,6 @@ def set_autolock_delay(client: Client, delay):
|
|||||||
[
|
[
|
||||||
pin_request(client),
|
pin_request(client),
|
||||||
messages.ButtonRequest,
|
messages.ButtonRequest,
|
||||||
(client.features.model == "R", messages.ButtonRequest),
|
|
||||||
messages.Success,
|
messages.Success,
|
||||||
messages.Features,
|
messages.Features,
|
||||||
]
|
]
|
||||||
@ -64,13 +63,7 @@ def test_apply_auto_lock_delay(client: Client):
|
|||||||
time.sleep(10.5) # sleep more than auto-lock delay
|
time.sleep(10.5) # sleep more than auto-lock delay
|
||||||
with client:
|
with client:
|
||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses([pin_request(client), messages.Address])
|
||||||
[
|
|
||||||
pin_request(client),
|
|
||||||
(client.features.model == "R", messages.ButtonRequest),
|
|
||||||
messages.Address,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
get_test_address(client)
|
get_test_address(client)
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +102,6 @@ def test_apply_auto_lock_delay_out_of_range(client: Client, seconds):
|
|||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
pin_request(client),
|
pin_request(client),
|
||||||
(client.features.model == "R", messages.ButtonRequest),
|
|
||||||
messages.Failure(code=messages.FailureType.ProcessError),
|
messages.Failure(code=messages.FailureType.ProcessError),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -26,10 +26,6 @@ EXPECTED_RESPONSES_NOPIN = [
|
|||||||
messages.Features,
|
messages.Features,
|
||||||
]
|
]
|
||||||
EXPECTED_RESPONSES_PIN_T1 = [messages.PinMatrixRequest()] + EXPECTED_RESPONSES_NOPIN
|
EXPECTED_RESPONSES_PIN_T1 = [messages.PinMatrixRequest()] + EXPECTED_RESPONSES_NOPIN
|
||||||
EXPECTED_RESPONSES_PIN_TR = [
|
|
||||||
messages.ButtonRequest(),
|
|
||||||
messages.ButtonRequest(),
|
|
||||||
] + EXPECTED_RESPONSES_NOPIN
|
|
||||||
EXPECTED_RESPONSES_PIN_TT = [messages.ButtonRequest()] + EXPECTED_RESPONSES_NOPIN
|
EXPECTED_RESPONSES_PIN_TT = [messages.ButtonRequest()] + EXPECTED_RESPONSES_NOPIN
|
||||||
|
|
||||||
PIN4 = "1234"
|
PIN4 = "1234"
|
||||||
@ -41,8 +37,6 @@ def _set_expected_responses(client: Client):
|
|||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
if client.features.model == "1":
|
if client.features.model == "1":
|
||||||
client.set_expected_responses(EXPECTED_RESPONSES_PIN_T1)
|
client.set_expected_responses(EXPECTED_RESPONSES_PIN_T1)
|
||||||
elif client.features.model == "R":
|
|
||||||
client.set_expected_responses(EXPECTED_RESPONSES_PIN_TR)
|
|
||||||
else:
|
else:
|
||||||
client.set_expected_responses(EXPECTED_RESPONSES_PIN_TT)
|
client.set_expected_responses(EXPECTED_RESPONSES_PIN_TT)
|
||||||
|
|
||||||
@ -392,10 +386,7 @@ def test_experimental_features(client: Client):
|
|||||||
client.lock()
|
client.lock()
|
||||||
with client:
|
with client:
|
||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
tr = client.features.model == "R"
|
client.set_expected_responses([messages.ButtonRequest, messages.Nonce])
|
||||||
client.set_expected_responses(
|
|
||||||
[messages.ButtonRequest, (tr, messages.ButtonRequest), messages.Nonce]
|
|
||||||
)
|
|
||||||
experimental_call()
|
experimental_call()
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,13 +33,11 @@ def _check_wipe_code(client: Client, pin: str, wipe_code: str):
|
|||||||
client.init_device()
|
client.init_device()
|
||||||
assert client.features.wipe_code_protection is True
|
assert client.features.wipe_code_protection is True
|
||||||
|
|
||||||
tr = client.features.model == "R"
|
|
||||||
|
|
||||||
# Try to change the PIN to the current wipe code value. The operation should fail.
|
# Try to change the PIN to the current wipe code value. The operation should fail.
|
||||||
with client, pytest.raises(TrezorFailure):
|
with client, pytest.raises(TrezorFailure):
|
||||||
client.use_pin_sequence([pin, wipe_code, wipe_code])
|
client.use_pin_sequence([pin, wipe_code, wipe_code])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[messages.ButtonRequest()] * (7 if tr else 5)
|
[messages.ButtonRequest()] * 6
|
||||||
+ [messages.Failure(code=messages.FailureType.PinInvalid)]
|
+ [messages.Failure(code=messages.FailureType.PinInvalid)]
|
||||||
)
|
)
|
||||||
device.change_pin(client)
|
device.change_pin(client)
|
||||||
@ -58,15 +56,12 @@ def test_set_remove_wipe_code(client: Client):
|
|||||||
# Test set wipe code.
|
# Test set wipe code.
|
||||||
assert client.features.wipe_code_protection is None
|
assert client.features.wipe_code_protection is None
|
||||||
|
|
||||||
tr = client.features.model == "R"
|
|
||||||
|
|
||||||
_ensure_unlocked(client, PIN4)
|
_ensure_unlocked(client, PIN4)
|
||||||
assert client.features.wipe_code_protection is False
|
assert client.features.wipe_code_protection is False
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[messages.ButtonRequest()] * (6 if tr else 5)
|
[messages.ButtonRequest()] * 6 + [messages.Success, messages.Features]
|
||||||
+ [messages.Success, messages.Features]
|
|
||||||
)
|
)
|
||||||
client.use_pin_sequence([PIN4, WIPE_CODE_MAX, WIPE_CODE_MAX])
|
client.use_pin_sequence([PIN4, WIPE_CODE_MAX, WIPE_CODE_MAX])
|
||||||
device.change_wipe_code(client)
|
device.change_wipe_code(client)
|
||||||
@ -78,8 +73,7 @@ def test_set_remove_wipe_code(client: Client):
|
|||||||
# Test change wipe code.
|
# Test change wipe code.
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[messages.ButtonRequest()] * (6 if tr else 5)
|
[messages.ButtonRequest()] * 5 + [messages.Success, messages.Features]
|
||||||
+ [messages.Success, messages.Features]
|
|
||||||
)
|
)
|
||||||
client.use_pin_sequence([PIN4, WIPE_CODE6, WIPE_CODE6])
|
client.use_pin_sequence([PIN4, WIPE_CODE6, WIPE_CODE6])
|
||||||
device.change_wipe_code(client)
|
device.change_wipe_code(client)
|
||||||
@ -91,8 +85,7 @@ def test_set_remove_wipe_code(client: Client):
|
|||||||
# Test remove wipe code.
|
# Test remove wipe code.
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[messages.ButtonRequest()] * (4 if tr else 3)
|
[messages.ButtonRequest()] * 3 + [messages.Success, messages.Features]
|
||||||
+ [messages.Success, messages.Features]
|
|
||||||
)
|
)
|
||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
device.change_wipe_code(client, remove=True)
|
device.change_wipe_code(client, remove=True)
|
||||||
@ -132,12 +125,9 @@ def test_set_wipe_code_mismatch(client: Client):
|
|||||||
def test_set_wipe_code_to_pin(client: Client):
|
def test_set_wipe_code_to_pin(client: Client):
|
||||||
_ensure_unlocked(client, PIN4)
|
_ensure_unlocked(client, PIN4)
|
||||||
|
|
||||||
tr = client.features.model == "R"
|
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[messages.ButtonRequest()] * (7 if tr else 6)
|
[messages.ButtonRequest()] * 7 + [messages.Success, messages.Features]
|
||||||
+ [messages.Success, messages.Features]
|
|
||||||
)
|
)
|
||||||
client.use_pin_sequence([PIN4, PIN4, WIPE_CODE4, WIPE_CODE4])
|
client.use_pin_sequence([PIN4, PIN4, WIPE_CODE4, WIPE_CODE4])
|
||||||
device.change_wipe_code(client)
|
device.change_wipe_code(client)
|
||||||
@ -148,12 +138,10 @@ def test_set_wipe_code_to_pin(client: Client):
|
|||||||
|
|
||||||
|
|
||||||
def test_set_pin_to_wipe_code(client: Client):
|
def test_set_pin_to_wipe_code(client: Client):
|
||||||
tr = client.features.model == "R"
|
|
||||||
|
|
||||||
# Set wipe code.
|
# Set wipe code.
|
||||||
with client:
|
with client:
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[messages.ButtonRequest()] * 4 + [messages.Success, messages.Features]
|
[messages.ButtonRequest()] * 5 + [messages.Success, messages.Features]
|
||||||
)
|
)
|
||||||
client.use_pin_sequence([WIPE_CODE4, WIPE_CODE4])
|
client.use_pin_sequence([WIPE_CODE4, WIPE_CODE4])
|
||||||
device.change_wipe_code(client)
|
device.change_wipe_code(client)
|
||||||
@ -161,7 +149,7 @@ def test_set_pin_to_wipe_code(client: Client):
|
|||||||
# Try to set the PIN to the current wipe code value.
|
# Try to set the PIN to the current wipe code value.
|
||||||
with client, pytest.raises(TrezorFailure):
|
with client, pytest.raises(TrezorFailure):
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[messages.ButtonRequest()] * (6 if tr else 4)
|
[messages.ButtonRequest()] * 6
|
||||||
+ [messages.Failure(code=messages.FailureType.PinInvalid)]
|
+ [messages.Failure(code=messages.FailureType.PinInvalid)]
|
||||||
)
|
)
|
||||||
client.use_pin_sequence([WIPE_CODE4, WIPE_CODE4])
|
client.use_pin_sequence([WIPE_CODE4, WIPE_CODE4])
|
||||||
|
@ -33,13 +33,9 @@ def _check_pin(client: Client, pin):
|
|||||||
assert client.features.pin_protection is True
|
assert client.features.pin_protection is True
|
||||||
assert client.features.unlocked is False
|
assert client.features.unlocked is False
|
||||||
|
|
||||||
tr = client.features.model == "R"
|
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
client.use_pin_sequence([pin])
|
client.use_pin_sequence([pin])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses([messages.ButtonRequest, messages.Address])
|
||||||
[messages.ButtonRequest, (tr, messages.ButtonRequest), messages.Address]
|
|
||||||
)
|
|
||||||
btc.get_address(client, "Testnet", PASSPHRASE_TEST_PATH)
|
btc.get_address(client, "Testnet", PASSPHRASE_TEST_PATH)
|
||||||
|
|
||||||
|
|
||||||
@ -55,8 +51,6 @@ def _check_no_pin(client: Client):
|
|||||||
def test_set_pin(client: Client):
|
def test_set_pin(client: Client):
|
||||||
assert client.features.pin_protection is False
|
assert client.features.pin_protection is False
|
||||||
|
|
||||||
tr = client.features.model == "R"
|
|
||||||
|
|
||||||
# Check that there's no PIN protection
|
# Check that there's no PIN protection
|
||||||
_check_no_pin(client)
|
_check_no_pin(client)
|
||||||
|
|
||||||
@ -64,8 +58,7 @@ def test_set_pin(client: Client):
|
|||||||
with client:
|
with client:
|
||||||
client.use_pin_sequence([PIN_MAX, PIN_MAX])
|
client.use_pin_sequence([PIN_MAX, PIN_MAX])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[messages.ButtonRequest] * (6 if tr else 4)
|
[messages.ButtonRequest] * 6 + [messages.Success, messages.Features]
|
||||||
+ [messages.Success, messages.Features]
|
|
||||||
)
|
)
|
||||||
device.change_pin(client)
|
device.change_pin(client)
|
||||||
|
|
||||||
@ -78,8 +71,6 @@ def test_set_pin(client: Client):
|
|||||||
def test_change_pin(client: Client):
|
def test_change_pin(client: Client):
|
||||||
assert client.features.pin_protection is True
|
assert client.features.pin_protection is True
|
||||||
|
|
||||||
tr = client.features.model == "R"
|
|
||||||
|
|
||||||
# Check current PIN value
|
# Check current PIN value
|
||||||
_check_pin(client, PIN4)
|
_check_pin(client, PIN4)
|
||||||
|
|
||||||
@ -87,8 +78,7 @@ def test_change_pin(client: Client):
|
|||||||
with client:
|
with client:
|
||||||
client.use_pin_sequence([PIN4, PIN_MAX, PIN_MAX])
|
client.use_pin_sequence([PIN4, PIN_MAX, PIN_MAX])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[messages.ButtonRequest] * (7 if tr else 5)
|
[messages.ButtonRequest] * 6 + [messages.Success, messages.Features]
|
||||||
+ [messages.Success, messages.Features]
|
|
||||||
)
|
)
|
||||||
device.change_pin(client)
|
device.change_pin(client)
|
||||||
|
|
||||||
@ -103,8 +93,6 @@ def test_change_pin(client: Client):
|
|||||||
def test_remove_pin(client: Client):
|
def test_remove_pin(client: Client):
|
||||||
assert client.features.pin_protection is True
|
assert client.features.pin_protection is True
|
||||||
|
|
||||||
tr = client.features.model == "R"
|
|
||||||
|
|
||||||
# Check current PIN value
|
# Check current PIN value
|
||||||
_check_pin(client, PIN4)
|
_check_pin(client, PIN4)
|
||||||
|
|
||||||
@ -112,8 +100,7 @@ def test_remove_pin(client: Client):
|
|||||||
with client:
|
with client:
|
||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[messages.ButtonRequest] * (4 if tr else 3)
|
[messages.ButtonRequest] * 3 + [messages.Success, messages.Features]
|
||||||
+ [messages.Success, messages.Features]
|
|
||||||
)
|
)
|
||||||
device.change_pin(client, remove=True)
|
device.change_pin(client, remove=True)
|
||||||
|
|
||||||
@ -158,13 +145,11 @@ def test_set_failed(client: Client):
|
|||||||
def test_change_failed(client: Client):
|
def test_change_failed(client: Client):
|
||||||
assert client.features.pin_protection is True
|
assert client.features.pin_protection is True
|
||||||
|
|
||||||
tr = client.features.model == "R"
|
|
||||||
|
|
||||||
# Check current PIN value
|
# Check current PIN value
|
||||||
_check_pin(client, PIN4)
|
_check_pin(client, PIN4)
|
||||||
|
|
||||||
# Let's set new PIN
|
# Let's set new PIN
|
||||||
def input_flow_tt():
|
def input_flow():
|
||||||
yield # do you want to change pin?
|
yield # do you want to change pin?
|
||||||
client.debug.press_yes()
|
client.debug.press_yes()
|
||||||
yield # enter current pin
|
yield # enter current pin
|
||||||
@ -178,28 +163,9 @@ def test_change_failed(client: Client):
|
|||||||
yield # enter current pin again
|
yield # enter current pin again
|
||||||
client.cancel()
|
client.cancel()
|
||||||
|
|
||||||
# Let's set new PIN
|
|
||||||
def input_flow_tr():
|
|
||||||
yield # do you want to change pin?
|
|
||||||
client.debug.press_yes()
|
|
||||||
yield # Enter old PIN?
|
|
||||||
client.debug.press_yes()
|
|
||||||
yield # enter current pin
|
|
||||||
client.debug.input(PIN4)
|
|
||||||
yield # enter new pin
|
|
||||||
client.debug.input("457891")
|
|
||||||
yield # enter new pin again (but different)
|
|
||||||
client.debug.input("381847")
|
|
||||||
|
|
||||||
# failed retry
|
|
||||||
yield # enter current pin again
|
|
||||||
client.cancel()
|
|
||||||
|
|
||||||
with client, pytest.raises(Cancelled):
|
with client, pytest.raises(Cancelled):
|
||||||
client.set_expected_responses(
|
client.set_expected_responses([messages.ButtonRequest] * 5 + [messages.Failure])
|
||||||
[messages.ButtonRequest] * (6 if tr else 5) + [messages.Failure]
|
client.set_input_flow(input_flow)
|
||||||
)
|
|
||||||
client.set_input_flow(input_flow_tr if tr else input_flow_tt)
|
|
||||||
|
|
||||||
device.change_pin(client)
|
device.change_pin(client)
|
||||||
|
|
||||||
|
@ -42,21 +42,17 @@ def test_correct_pin(client: Client):
|
|||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
# Expected responses differ between T1 and TT
|
# Expected responses differ between T1 and TT
|
||||||
is_t1 = client.features.model == "1"
|
is_t1 = client.features.model == "1"
|
||||||
is_tr = client.features.model == "R"
|
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
(is_t1, messages.PinMatrixRequest),
|
(is_t1, messages.PinMatrixRequest),
|
||||||
(
|
(
|
||||||
is_tr,
|
not is_t1,
|
||||||
messages.ButtonRequest(code=messages.ButtonRequestType.Other),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
not is_t1 or is_tr,
|
|
||||||
messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry),
|
messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry),
|
||||||
),
|
),
|
||||||
messages.Address,
|
messages.Address,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
# client.set_expected_responses([messages.ButtonRequest, messages.Address])
|
||||||
get_test_address(client)
|
get_test_address(client)
|
||||||
|
|
||||||
|
|
||||||
@ -72,13 +68,10 @@ def test_incorrect_pin_t1(client: Client):
|
|||||||
def test_incorrect_pin_t2(client: Client):
|
def test_incorrect_pin_t2(client: Client):
|
||||||
with client:
|
with client:
|
||||||
# After first incorrect attempt, TT will not raise an error, but instead ask for another attempt
|
# After first incorrect attempt, TT will not raise an error, but instead ask for another attempt
|
||||||
is_tr = client.features.model == "R"
|
|
||||||
client.use_pin_sequence([BAD_PIN, PIN4])
|
client.use_pin_sequence([BAD_PIN, PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
(is_tr, messages.ButtonRequest(code=messages.ButtonRequestType.Other)),
|
|
||||||
messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry),
|
messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry),
|
||||||
(is_tr, messages.ButtonRequest(code=messages.ButtonRequestType.Other)),
|
|
||||||
messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry),
|
messages.ButtonRequest(code=messages.ButtonRequestType.PinEntry),
|
||||||
messages.Address,
|
messages.Address,
|
||||||
]
|
]
|
||||||
@ -106,7 +99,7 @@ def test_exponential_backoff_t1(client: Client):
|
|||||||
|
|
||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
def test_exponential_backoff_t2(client: Client):
|
def test_exponential_backoff_t2(client: Client):
|
||||||
def input_flow_tt():
|
def input_flow():
|
||||||
"""Inputting some bad PINs and finally the correct one"""
|
"""Inputting some bad PINs and finally the correct one"""
|
||||||
yield # PIN entry
|
yield # PIN entry
|
||||||
for attempt in range(3):
|
for attempt in range(3):
|
||||||
@ -116,21 +109,6 @@ def test_exponential_backoff_t2(client: Client):
|
|||||||
_check_backoff_time(attempt, start)
|
_check_backoff_time(attempt, start)
|
||||||
client.debug.input(PIN4)
|
client.debug.input(PIN4)
|
||||||
|
|
||||||
def input_flow_tr():
|
|
||||||
"""Inputting some bad PINs and finally the correct one"""
|
|
||||||
yield # Enter your PIN
|
|
||||||
client.debug.press_yes()
|
|
||||||
yield # PIN entry
|
|
||||||
for attempt in range(3):
|
|
||||||
start = time.time()
|
|
||||||
client.debug.input(BAD_PIN)
|
|
||||||
yield # PIN entry
|
|
||||||
client.debug.press_yes()
|
|
||||||
yield # Wrong PIN, enter again
|
|
||||||
_check_backoff_time(attempt, start)
|
|
||||||
client.debug.input(PIN4)
|
|
||||||
|
|
||||||
with client:
|
with client:
|
||||||
tr = client.features.model == "R"
|
client.set_input_flow(input_flow)
|
||||||
client.set_input_flow(input_flow_tr if tr else input_flow_tt)
|
|
||||||
get_test_address(client)
|
get_test_address(client)
|
||||||
|
@ -44,17 +44,12 @@ PIN4 = "1234"
|
|||||||
pytestmark = pytest.mark.setup_client(pin=PIN4, passphrase=True)
|
pytestmark = pytest.mark.setup_client(pin=PIN4, passphrase=True)
|
||||||
|
|
||||||
|
|
||||||
def _pin_requests(client: Client) -> list:
|
def _pin_request(client: Client):
|
||||||
"""Get appropriate PIN requests for each model"""
|
"""Get appropriate PIN request for each model"""
|
||||||
if client.features.model == "1":
|
if client.features.model == "1":
|
||||||
return [messages.PinMatrixRequest]
|
return messages.PinMatrixRequest
|
||||||
elif client.features.model == "R":
|
|
||||||
return [
|
|
||||||
messages.ButtonRequest(code=B.Other),
|
|
||||||
messages.ButtonRequest(code=B.PinEntry),
|
|
||||||
]
|
|
||||||
else:
|
else:
|
||||||
return [messages.ButtonRequest(code=B.PinEntry)]
|
return messages.ButtonRequest(code=B.PinEntry)
|
||||||
|
|
||||||
|
|
||||||
def _assert_protection(
|
def _assert_protection(
|
||||||
@ -108,7 +103,7 @@ def test_apply_settings(client: Client):
|
|||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
messages.ButtonRequest,
|
messages.ButtonRequest,
|
||||||
messages.Success,
|
messages.Success,
|
||||||
messages.Features,
|
messages.Features,
|
||||||
@ -126,9 +121,9 @@ def test_change_pin_t1(client: Client):
|
|||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
messages.ButtonRequest,
|
messages.ButtonRequest,
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
messages.Success,
|
messages.Success,
|
||||||
messages.Features,
|
messages.Features,
|
||||||
]
|
]
|
||||||
@ -143,11 +138,12 @@ def test_change_pin_t2(client: Client):
|
|||||||
client.use_pin_sequence([PIN4, PIN4, PIN4, PIN4])
|
client.use_pin_sequence([PIN4, PIN4, PIN4, PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
messages.ButtonRequest,
|
messages.ButtonRequest,
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
messages.ButtonRequest(code=B.PinEntry),
|
_pin_request(client),
|
||||||
*_pin_requests(client),
|
messages.ButtonRequest,
|
||||||
|
_pin_request(client),
|
||||||
messages.ButtonRequest,
|
messages.ButtonRequest,
|
||||||
messages.Success,
|
messages.Success,
|
||||||
messages.Features,
|
messages.Features,
|
||||||
@ -170,7 +166,7 @@ def test_get_entropy(client: Client):
|
|||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
messages.ButtonRequest(code=B.ProtectCall),
|
messages.ButtonRequest(code=B.ProtectCall),
|
||||||
messages.Entropy,
|
messages.Entropy,
|
||||||
]
|
]
|
||||||
@ -184,7 +180,7 @@ def test_get_public_key(client: Client):
|
|||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
messages.PassphraseRequest,
|
messages.PassphraseRequest,
|
||||||
messages.PublicKey,
|
messages.PublicKey,
|
||||||
]
|
]
|
||||||
@ -198,7 +194,7 @@ def test_get_address(client: Client):
|
|||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
messages.PassphraseRequest,
|
messages.PassphraseRequest,
|
||||||
messages.Address,
|
messages.Address,
|
||||||
]
|
]
|
||||||
@ -293,7 +289,7 @@ def test_sign_message(client: Client):
|
|||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
messages.PassphraseRequest,
|
messages.PassphraseRequest,
|
||||||
messages.ButtonRequest,
|
messages.ButtonRequest,
|
||||||
messages.ButtonRequest,
|
messages.ButtonRequest,
|
||||||
@ -336,7 +332,7 @@ def test_verify_message_t2(client: Client):
|
|||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
messages.ButtonRequest,
|
messages.ButtonRequest,
|
||||||
messages.ButtonRequest,
|
messages.ButtonRequest,
|
||||||
messages.ButtonRequest,
|
messages.ButtonRequest,
|
||||||
@ -376,7 +372,7 @@ def test_signtx(client: Client):
|
|||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
client.set_expected_responses(
|
client.set_expected_responses(
|
||||||
[
|
[
|
||||||
*_pin_requests(client),
|
_pin_request(client),
|
||||||
messages.PassphraseRequest,
|
messages.PassphraseRequest,
|
||||||
request_input(0),
|
request_input(0),
|
||||||
request_output(0),
|
request_output(0),
|
||||||
@ -412,7 +408,7 @@ def test_unlocked(client: Client):
|
|||||||
_assert_protection(client, passphrase=False)
|
_assert_protection(client, passphrase=False)
|
||||||
with client:
|
with client:
|
||||||
client.use_pin_sequence([PIN4])
|
client.use_pin_sequence([PIN4])
|
||||||
client.set_expected_responses([*_pin_requests(client), messages.Address])
|
client.set_expected_responses([_pin_request(client), messages.Address])
|
||||||
get_test_address(client)
|
get_test_address(client)
|
||||||
|
|
||||||
client.init_device()
|
client.init_device()
|
||||||
|
@ -35,7 +35,6 @@ def test_clear_session(client: Client):
|
|||||||
is_trezor1 = client.features.model == "1"
|
is_trezor1 = client.features.model == "1"
|
||||||
init_responses = [
|
init_responses = [
|
||||||
messages.PinMatrixRequest if is_trezor1 else messages.ButtonRequest,
|
messages.PinMatrixRequest if is_trezor1 else messages.ButtonRequest,
|
||||||
(client.features.model == "R", messages.ButtonRequest),
|
|
||||||
messages.PassphraseRequest,
|
messages.PassphraseRequest,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user