test: Add test for progressive storage version upgrades without unlocking in between.

pull/1546/head
Andrew Kozlik 4 years ago committed by Andrew Kozlik
parent aaa1ea6352
commit 9bd4465fbf

@ -96,3 +96,10 @@ def for_all(*args, legacy_minimum_version=(1, 0, 0), core_minimum_version=(2, 0,
return pytest.mark.skip("no versions are applicable")
return pytest.mark.parametrize("gen, tag", all_params)
def for_tags(*args):
enabled_gens = SELECTED_GENS or ("core", "legacy")
return pytest.mark.parametrize(
"gen, tags", [(gen, tags) for gen, tags in args if gen in enabled_gens]
)

@ -22,7 +22,7 @@ from ..click_tests import recovery
from ..common import MNEMONIC_SLIP39_BASIC_20_3of6, MNEMONIC_SLIP39_BASIC_20_3of6_SECRET
from ..device_handler import BackgroundDeviceHandler
from ..emulators import ALL_TAGS, EmulatorWrapper
from . import for_all
from . import for_all, for_tags
MINIMUM_FIRMWARE_VERSION["1"] = (1, 0, 0)
MINIMUM_FIRMWARE_VERSION["T"] = (2, 0, 0)
@ -97,6 +97,52 @@ def test_upgrade_load_pin(gen, tag):
assert emu.client.features.language == LANGUAGE
# Test progressive upgrade of storage versions without unlocking in between.
# Legacy storage: until legacy-v1.7.3 (pre-norcow)
# Storage Version 0: until core-v2.0.9 (basic norcow)
# Storage Version 1: since legacy-v1.8.0 and core-v2.1.0 (encryption)
# Storage Version 2: since legacy-v1.9.0 and core-v2.3.0 (wipe code)
# Storage Version 3: since legacy-v1.10.0 and core-v2.4.0 (long PIN)
@for_tags(
("legacy", ["v1.7.0", "v1.8.0", "v1.9.0"]),
("legacy", ["v1.7.0", "v1.8.0"]),
("legacy", ["v1.7.0", "v1.9.0"]),
("legacy", ["v1.8.0", "v1.9.0"]),
)
def test_storage_upgrade_progressive(gen, tags):
PIN = "1234"
def asserts(client):
assert client.features.pin_protection
assert not client.features.passphrase_protection
assert client.features.initialized
assert client.features.label == LABEL
client.use_pin_sequence([PIN])
assert btc.get_address(client, "Bitcoin", PATH) == ADDRESS
with EmulatorWrapper(gen, tags[0]) as emu:
debuglink.load_device_by_mnemonic(
emu.client,
mnemonic=MNEMONIC,
pin=PIN,
passphrase_protection=False,
label=LABEL,
language=LANGUAGE,
)
device_id = emu.client.features.device_id
asserts(emu.client)
storage = emu.get_storage()
for tag in tags[1:]:
with EmulatorWrapper(gen, tag, storage=storage) as emu:
storage = emu.get_storage()
with EmulatorWrapper(gen, storage=storage) as emu:
assert device_id == emu.client.features.device_id
asserts(emu.client)
assert emu.client.features.language == LANGUAGE
@for_all("legacy")
def test_upgrade_reset(gen, tag):
def asserts(client):

Loading…
Cancel
Save