mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-12 08:20:56 +00:00
tests/ui: reseed each ui test before running it
This commit is contained in:
parent
8796ca96b9
commit
0c820091a8
@ -99,7 +99,6 @@ def client(request):
|
|||||||
passphrase=False,
|
passphrase=False,
|
||||||
needs_backup=False,
|
needs_backup=False,
|
||||||
no_backup=False,
|
no_backup=False,
|
||||||
random_seed=None,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
marker = request.node.get_closest_marker("setup_client")
|
marker = request.node.get_closest_marker("setup_client")
|
||||||
@ -129,10 +128,16 @@ def client(request):
|
|||||||
|
|
||||||
client.open()
|
client.open()
|
||||||
|
|
||||||
if setup_params["random_seed"] is not None:
|
test_ui = request.config.getoption("ui")
|
||||||
client.debug.reseed(setup_params["random_seed"])
|
if test_ui not in ("", "record", "test"):
|
||||||
|
raise ValueError("Invalid ui option.")
|
||||||
|
|
||||||
with ui_tests.screen_recording(client, request):
|
run_ui_tests = not request.node.get_closest_marker("skip_ui") and test_ui
|
||||||
|
if run_ui_tests:
|
||||||
|
client.debug.reseed(0)
|
||||||
|
with ui_tests.screen_recording(client, request):
|
||||||
|
yield client
|
||||||
|
else:
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
client.close()
|
client.close()
|
||||||
|
@ -32,7 +32,7 @@ from ..common import (
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip_t1 # TODO we want this for t1 too
|
@pytest.mark.skip_t1 # TODO we want this for t1 too
|
||||||
@pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC12, random_seed=0)
|
@pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC12)
|
||||||
def test_backup_bip39(client):
|
def test_backup_bip39(client):
|
||||||
assert client.features.needs_backup is True
|
assert client.features.needs_backup is True
|
||||||
mnemonic = None
|
mnemonic = None
|
||||||
@ -71,9 +71,7 @@ def test_backup_bip39(client):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
@pytest.mark.setup_client(
|
@pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC_SLIP39_BASIC_20_3of6)
|
||||||
needs_backup=True, mnemonic=MNEMONIC_SLIP39_BASIC_20_3of6, random_seed=0
|
|
||||||
)
|
|
||||||
def test_backup_slip39_basic(client):
|
def test_backup_slip39_basic(client):
|
||||||
assert client.features.needs_backup is True
|
assert client.features.needs_backup is True
|
||||||
mnemonics = []
|
mnemonics = []
|
||||||
@ -138,9 +136,7 @@ def test_backup_slip39_basic(client):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
@pytest.mark.setup_client(
|
@pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC_SLIP39_ADVANCED_20)
|
||||||
needs_backup=True, mnemonic=MNEMONIC_SLIP39_ADVANCED_20, random_seed=0
|
|
||||||
)
|
|
||||||
def test_backup_slip39_advanced(client):
|
def test_backup_slip39_advanced(client):
|
||||||
assert client.features.needs_backup is True
|
assert client.features.needs_backup is True
|
||||||
mnemonics = []
|
mnemonics = []
|
||||||
|
@ -100,7 +100,7 @@ def _check_wipe_code(client, pin, wipe_code):
|
|||||||
device.change_pin(client)
|
device.change_pin(client)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(pin=PIN4, random_seed=0)
|
@pytest.mark.setup_client(pin=PIN4)
|
||||||
def test_set_remove_wipe_code(client):
|
def test_set_remove_wipe_code(client):
|
||||||
# Test set wipe code.
|
# Test set wipe code.
|
||||||
assert client.features.wipe_code_protection is False
|
assert client.features.wipe_code_protection is False
|
||||||
@ -143,7 +143,7 @@ def test_set_remove_wipe_code(client):
|
|||||||
assert client.features.wipe_code_protection is False
|
assert client.features.wipe_code_protection is False
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(random_seed=0)
|
@pytest.mark.setup_client()
|
||||||
def test_set_wipe_code_mismatch(client):
|
def test_set_wipe_code_mismatch(client):
|
||||||
# Let's set a wipe code.
|
# Let's set a wipe code.
|
||||||
def input_flow():
|
def input_flow():
|
||||||
@ -171,7 +171,7 @@ def test_set_wipe_code_mismatch(client):
|
|||||||
assert client.features.wipe_code_protection is False
|
assert client.features.wipe_code_protection is False
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(pin=PIN4, random_seed=0)
|
@pytest.mark.setup_client(pin=PIN4)
|
||||||
def test_set_wipe_code_to_pin(client):
|
def test_set_wipe_code_to_pin(client):
|
||||||
def input_flow():
|
def input_flow():
|
||||||
yield # do you want to set the wipe code?
|
yield # do you want to set the wipe code?
|
||||||
@ -202,7 +202,7 @@ def test_set_wipe_code_to_pin(client):
|
|||||||
_check_wipe_code(client, PIN4, WIPE_CODE4)
|
_check_wipe_code(client, PIN4, WIPE_CODE4)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(random_seed=0)
|
@pytest.mark.setup_client()
|
||||||
def test_set_pin_to_wipe_code(client):
|
def test_set_pin_to_wipe_code(client):
|
||||||
# Set wipe code.
|
# Set wipe code.
|
||||||
with client:
|
with client:
|
||||||
@ -223,7 +223,7 @@ def test_set_pin_to_wipe_code(client):
|
|||||||
device.change_pin(client)
|
device.change_pin(client)
|
||||||
|
|
||||||
|
|
||||||
# TODO: this UI test should not be skipped, but when setting random_seed=0 it fails
|
# TODO: this UI test should not be skipped, but because of the reseed it fails
|
||||||
# on device id match and I am not sure why
|
# on device id match and I am not sure why
|
||||||
@pytest.mark.setup_client(pin=PIN4)
|
@pytest.mark.setup_client(pin=PIN4)
|
||||||
@pytest.mark.skip_ui
|
@pytest.mark.skip_ui
|
||||||
|
@ -96,7 +96,7 @@ def _check_no_pin(client):
|
|||||||
assert client.features.pin_protection is False
|
assert client.features.pin_protection is False
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(random_seed=0)
|
@pytest.mark.setup_client()
|
||||||
def test_set_pin(client):
|
def test_set_pin(client):
|
||||||
assert client.features.pin_protection is False
|
assert client.features.pin_protection is False
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ def test_set_pin(client):
|
|||||||
_check_pin(client, PIN6)
|
_check_pin(client, PIN6)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(pin=PIN4, random_seed=0)
|
@pytest.mark.setup_client(pin=PIN4)
|
||||||
def test_change_pin(client):
|
def test_change_pin(client):
|
||||||
assert client.features.pin_protection is True
|
assert client.features.pin_protection is True
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ def test_change_pin(client):
|
|||||||
_check_pin(client, PIN6)
|
_check_pin(client, PIN6)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(pin=PIN4, random_seed=0)
|
@pytest.mark.setup_client(pin=PIN4)
|
||||||
def test_remove_pin(client):
|
def test_remove_pin(client):
|
||||||
assert client.features.pin_protection is True
|
assert client.features.pin_protection is True
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ def test_remove_pin(client):
|
|||||||
_check_no_pin(client)
|
_check_no_pin(client)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(random_seed=0)
|
@pytest.mark.setup_client()
|
||||||
def test_set_failed(client):
|
def test_set_failed(client):
|
||||||
assert client.features.pin_protection is False
|
assert client.features.pin_protection is False
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ def test_set_failed(client):
|
|||||||
_check_no_pin(client)
|
_check_no_pin(client)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(pin=PIN4, random_seed=0)
|
@pytest.mark.setup_client(pin=PIN4)
|
||||||
def test_change_failed(client):
|
def test_change_failed(client):
|
||||||
assert client.features.pin_protection is True
|
assert client.features.pin_protection is True
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ from ..common import MNEMONIC12
|
|||||||
|
|
||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
class TestMsgRecoverydeviceT2:
|
class TestMsgRecoverydeviceT2:
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_pin_passphrase(self, client):
|
def test_pin_passphrase(self, client):
|
||||||
mnemonic = MNEMONIC12.split(" ")
|
mnemonic = MNEMONIC12.split(" ")
|
||||||
ret = client.call_raw(
|
ret = client.call_raw(
|
||||||
|
@ -66,7 +66,7 @@ def test_secret(client, shares, secret):
|
|||||||
assert debug.read_mnemonic_secret().hex() == secret
|
assert debug.read_mnemonic_secret().hex() == secret
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_extra_share_entered(client):
|
def test_extra_share_entered(client):
|
||||||
debug = client.debug
|
debug = client.debug
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ def test_secret(client, shares, secret):
|
|||||||
assert debug.read_mnemonic_secret().hex() == secret
|
assert debug.read_mnemonic_secret().hex() == secret
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_recover_with_pin_passphrase(client):
|
def test_recover_with_pin_passphrase(client):
|
||||||
debug = client.debug
|
debug = client.debug
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ EXTERNAL_ENTROPY = b"zlutoucky kun upel divoke ody" * 2
|
|||||||
|
|
||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
class TestMsgResetDeviceT2:
|
class TestMsgResetDeviceT2:
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_reset_device(self, client):
|
def test_reset_device(self, client):
|
||||||
mnemonic = None
|
mnemonic = None
|
||||||
strength = 128
|
strength = 128
|
||||||
@ -110,7 +110,7 @@ class TestMsgResetDeviceT2:
|
|||||||
with pytest.raises(TrezorFailure, match="ProcessError: Seed already backed up"):
|
with pytest.raises(TrezorFailure, match="ProcessError: Seed already backed up"):
|
||||||
device.backup(client)
|
device.backup(client)
|
||||||
|
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_reset_device_pin(self, client):
|
def test_reset_device_pin(self, client):
|
||||||
mnemonic = None
|
mnemonic = None
|
||||||
strength = 128
|
strength = 128
|
||||||
@ -207,7 +207,7 @@ class TestMsgResetDeviceT2:
|
|||||||
assert resp.pin_protection is True
|
assert resp.pin_protection is True
|
||||||
assert resp.passphrase_protection is True
|
assert resp.passphrase_protection is True
|
||||||
|
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_failed_pin(self, client):
|
def test_failed_pin(self, client):
|
||||||
# external_entropy = b'zlutoucky kun upel divoke ody' * 2
|
# external_entropy = b'zlutoucky kun upel divoke ody' * 2
|
||||||
strength = 128
|
strength = 128
|
||||||
|
@ -31,7 +31,7 @@ EXTERNAL_ENTROPY = b"zlutoucky kun upel divoke ody" * 2
|
|||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
class TestMsgResetDeviceT2:
|
class TestMsgResetDeviceT2:
|
||||||
# TODO: test with different options
|
# TODO: test with different options
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_reset_device_slip39_advanced(self, client):
|
def test_reset_device_slip39_advanced(self, client):
|
||||||
strength = 128
|
strength = 128
|
||||||
word_count = 20
|
word_count = 20
|
||||||
|
@ -36,7 +36,7 @@ from ..common import (
|
|||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
class TestMsgResetDeviceT2:
|
class TestMsgResetDeviceT2:
|
||||||
# TODO: test with different options
|
# TODO: test with different options
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_reset_device_slip39_basic(self, client):
|
def test_reset_device_slip39_basic(self, client):
|
||||||
strength = 128
|
strength = 128
|
||||||
member_threshold = 3
|
member_threshold = 3
|
||||||
|
@ -178,7 +178,7 @@ VECTORS = [
|
|||||||
|
|
||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
@pytest.mark.parametrize("backup_type, backup_flow", VECTORS)
|
@pytest.mark.parametrize("backup_type, backup_flow", VECTORS)
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_skip_backup_msg(client, backup_type, backup_flow):
|
def test_skip_backup_msg(client, backup_type, backup_flow):
|
||||||
|
|
||||||
os_urandom = mock.Mock(return_value=EXTERNAL_ENTROPY)
|
os_urandom = mock.Mock(return_value=EXTERNAL_ENTROPY)
|
||||||
@ -213,7 +213,7 @@ def test_skip_backup_msg(client, backup_type, backup_flow):
|
|||||||
|
|
||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
@pytest.mark.parametrize("backup_type, backup_flow", VECTORS)
|
@pytest.mark.parametrize("backup_type, backup_flow", VECTORS)
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_skip_backup_manual(client, backup_type, backup_flow):
|
def test_skip_backup_manual(client, backup_type, backup_flow):
|
||||||
def reset_skip_input_flow():
|
def reset_skip_input_flow():
|
||||||
yield # Confirm Recovery
|
yield # Confirm Recovery
|
||||||
|
@ -28,7 +28,7 @@ from ..common import EXTERNAL_ENTROPY, click_through, read_and_confirm_mnemonic
|
|||||||
|
|
||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
@pytest.mark.skip_ui
|
@pytest.mark.skip_ui
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_reset_recovery(client):
|
def test_reset_recovery(client):
|
||||||
mnemonic = reset(client)
|
mnemonic = reset(client)
|
||||||
address_before = btc.get_address(client, "Bitcoin", parse_path("44'/0'/0'/0/0"))
|
address_before = btc.get_address(client, "Bitcoin", parse_path("44'/0'/0'/0/0"))
|
||||||
|
@ -32,7 +32,7 @@ from ..common import (
|
|||||||
|
|
||||||
@pytest.mark.skip_t1
|
@pytest.mark.skip_t1
|
||||||
@pytest.mark.skip_ui
|
@pytest.mark.skip_ui
|
||||||
@pytest.mark.setup_client(uninitialized=True, random_seed=0)
|
@pytest.mark.setup_client(uninitialized=True)
|
||||||
def test_reset_recovery(client):
|
def test_reset_recovery(client):
|
||||||
mnemonics = reset(client)
|
mnemonics = reset(client)
|
||||||
address_before = btc.get_address(client, "Bitcoin", parse_path("44'/0'/0'/0/0"))
|
address_before = btc.get_address(client, "Bitcoin", parse_path("44'/0'/0'/0/0"))
|
||||||
|
@ -87,10 +87,6 @@ def _process_tested(fixture_test_path, test_name):
|
|||||||
@contextmanager
|
@contextmanager
|
||||||
def screen_recording(client, request):
|
def screen_recording(client, request):
|
||||||
test_ui = request.config.getoption("ui")
|
test_ui = request.config.getoption("ui")
|
||||||
if request.node.get_closest_marker("skip_ui") or not test_ui:
|
|
||||||
yield
|
|
||||||
return
|
|
||||||
|
|
||||||
test_name = _get_test_dirname(request.node)
|
test_name = _get_test_dirname(request.node)
|
||||||
fixture_test_path = Path(__file__).parent.resolve() / "fixtures" / test_name
|
fixture_test_path = Path(__file__).parent.resolve() / "fixtures" / test_name
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user