From 24e86305a8b1dec32a18ef0214370e4913cca89e Mon Sep 17 00:00:00 2001 From: matejcik Date: Fri, 10 Jan 2025 13:40:25 +0100 Subject: [PATCH] fix(tests): implement expected responses for entropy check fixes #4464 --- .../reset_recovery/test_reset_bip39_t2.py | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/device_tests/reset_recovery/test_reset_bip39_t2.py b/tests/device_tests/reset_recovery/test_reset_bip39_t2.py index d3ef43fd155..f07aca88c38 100644 --- a/tests/device_tests/reset_recovery/test_reset_bip39_t2.py +++ b/tests/device_tests/reset_recovery/test_reset_bip39_t2.py @@ -38,6 +38,21 @@ def reset_device(client: Client, strength: int): IF = InputFlowBip39ResetBackup(client) client.set_input_flow(IF.get()) + client.set_expected_responses( + [ + messages.ButtonRequest(name="setup_device"), + messages.EntropyRequest, + messages.ButtonRequest(name="backup_device"), + messages.ButtonRequest(name="backup_device"), + messages.ButtonRequest(name="backup_intro"), + messages.ButtonRequest(name="backup_warning"), + messages.ButtonRequest(name="share_words"), + messages.ButtonRequest(name="success_backup"), + messages.Success, + messages.Features, + ] + ) + # No PIN, no passphrase, don't display random device.setup( client, @@ -249,3 +264,37 @@ def test_already_initialized(client: Client): pin_protection=True, label="label", ) + + +@pytest.mark.setup_client(uninitialized=True) +def test_entropy_check(client: Client): + with client: + client.set_expected_responses( + [ + messages.ButtonRequest(name="setup_device"), + messages.ButtonRequest(name="confirm_setup_device"), + messages.EntropyRequest, + messages.EntropyCheckReady, + messages.PublicKey, + messages.PublicKey, + messages.EntropyRequest, + messages.EntropyCheckReady, + messages.PublicKey, + messages.PublicKey, + messages.EntropyRequest, + messages.EntropyCheckReady, + messages.PublicKey, + messages.PublicKey, + messages.ButtonRequest(name="backup_device"), + messages.Success, + messages.Features, + ] + ) + device.setup( + client, + strength=128, + entropy_check_count=2, + backup_type=messages.BackupType.Bip39, + skip_backup=True, + _get_entropy=MOCK_GET_ENTROPY, + )