2023-05-04 12:16:40 +00:00
|
|
|
# This file is part of the Trezor project.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the License along with this library.
|
|
|
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
|
|
|
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from trezorlib import device, messages
|
|
|
|
|
|
|
|
from ..common import WITH_MOCK_URANDOM
|
|
|
|
from . import reset
|
2023-05-12 09:19:35 +00:00
|
|
|
from .common import go_next
|
2023-05-04 12:16:40 +00:00
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from ..device_handler import BackgroundDeviceHandler
|
|
|
|
|
|
|
|
|
2024-09-02 11:01:16 +00:00
|
|
|
pytestmark = pytest.mark.models("core")
|
2023-05-04 12:16:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.setup_client(uninitialized=True)
|
|
|
|
@WITH_MOCK_URANDOM
|
|
|
|
def test_reset_bip39(device_handler: "BackgroundDeviceHandler"):
|
|
|
|
features = device_handler.features()
|
|
|
|
debug = device_handler.debuglink()
|
|
|
|
|
|
|
|
assert features.initialized is False
|
|
|
|
|
|
|
|
device_handler.run(
|
|
|
|
device.reset,
|
|
|
|
strength=128,
|
|
|
|
backup_type=messages.BackupType.Bip39,
|
|
|
|
pin_protection=False,
|
|
|
|
)
|
|
|
|
|
|
|
|
# confirm new wallet
|
|
|
|
reset.confirm_new_wallet(debug)
|
|
|
|
|
|
|
|
# confirm back up
|
2023-08-11 15:57:32 +00:00
|
|
|
reset.confirm_read(debug)
|
2023-05-04 12:16:40 +00:00
|
|
|
|
2024-06-04 13:40:42 +00:00
|
|
|
# confirm backup intro
|
|
|
|
reset.confirm_read(debug, middle_r=True)
|
|
|
|
|
2023-06-26 08:50:28 +00:00
|
|
|
# confirm backup warning
|
2023-08-11 15:57:32 +00:00
|
|
|
reset.confirm_read(debug, middle_r=True)
|
2023-05-04 12:16:40 +00:00
|
|
|
|
|
|
|
# read words
|
2024-04-23 10:26:46 +00:00
|
|
|
words = reset.read_words(debug)
|
2023-05-04 12:16:40 +00:00
|
|
|
|
|
|
|
# confirm words
|
|
|
|
reset.confirm_words(debug, words)
|
|
|
|
|
|
|
|
# confirm backup done
|
2023-08-11 15:57:32 +00:00
|
|
|
reset.confirm_read(debug)
|
2023-05-04 12:16:40 +00:00
|
|
|
|
|
|
|
# Your backup is done
|
2023-05-12 09:19:35 +00:00
|
|
|
go_next(debug)
|
2023-05-04 12:16:40 +00:00
|
|
|
|
|
|
|
# TODO: some validation of the generated secret?
|
|
|
|
|
|
|
|
assert device_handler.result() == "Initialized"
|
|
|
|
features = device_handler.features()
|
|
|
|
assert features.initialized is True
|
2024-05-23 14:09:16 +00:00
|
|
|
assert features.backup_availability == messages.BackupAvailability.NotAvailable
|
2023-05-04 12:16:40 +00:00
|
|
|
assert features.pin_protection is False
|
|
|
|
assert features.passphrase_protection is False
|
|
|
|
assert features.backup_type is messages.BackupType.Bip39
|