mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-25 17:09:44 +00:00
tests: test reset device also with another strengths
This commit is contained in:
parent
0f95eff4ff
commit
ad25096f90
@ -22,13 +22,9 @@ from trezorlib import device, messages as proto
|
||||
from ..common import generate_entropy
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgResetDevice:
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device(self, client):
|
||||
def reset_device(client, strength):
|
||||
# No PIN, no passphrase
|
||||
external_entropy = b"zlutoucky kun upel divoke ody" * 2
|
||||
strength = 128
|
||||
|
||||
ret = client.call_raw(
|
||||
proto.ResetDevice(
|
||||
@ -91,10 +87,21 @@ class TestMsgResetDevice:
|
||||
resp = client.call_raw(proto.GetAddress())
|
||||
assert isinstance(resp, proto.Address)
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
class TestMsgResetDevice:
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_pin(self, client):
|
||||
def test_reset_device_128(self, client):
|
||||
reset_device(client, 128)
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_192(self, client):
|
||||
reset_device(client, 192)
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_256_pin(self, client):
|
||||
external_entropy = b"zlutoucky kun upel divoke ody" * 2
|
||||
strength = 128
|
||||
strength = 256
|
||||
|
||||
ret = client.call_raw(
|
||||
proto.ResetDevice(
|
||||
|
@ -31,14 +31,12 @@ from ..common import (
|
||||
)
|
||||
|
||||
EXTERNAL_ENTROPY = b"zlutoucky kun upel divoke ody" * 2
|
||||
STRENGTH_TO_WORDS = {128: 12, 192: 18, 256: 24}
|
||||
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
class TestMsgResetDeviceT2:
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device(self, client):
|
||||
def reset_device(client, strength):
|
||||
words = STRENGTH_TO_WORDS[strength]
|
||||
mnemonic = None
|
||||
strength = 128
|
||||
|
||||
def input_flow():
|
||||
nonlocal mnemonic
|
||||
@ -50,7 +48,7 @@ class TestMsgResetDeviceT2:
|
||||
# mnemonic phrases
|
||||
btn_code = yield
|
||||
assert btn_code == B.ResetDevice
|
||||
mnemonic = read_and_confirm_mnemonic(client.debug, words=12)
|
||||
mnemonic = read_and_confirm_mnemonic(client.debug, words=words)
|
||||
|
||||
# confirm recovery seed check
|
||||
btn_code = yield
|
||||
@ -110,10 +108,21 @@ class TestMsgResetDeviceT2:
|
||||
with pytest.raises(TrezorFailure, match="ProcessError: Seed already backed up"):
|
||||
device.backup(client)
|
||||
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
class TestMsgResetDeviceT2:
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device(self, client):
|
||||
reset_device(client, 128) # 12 words
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_192(self, client):
|
||||
reset_device(client, 192) # 18 words
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_pin(self, client):
|
||||
mnemonic = None
|
||||
strength = 128
|
||||
strength = 256 # 24 words
|
||||
|
||||
def input_flow():
|
||||
nonlocal mnemonic
|
||||
@ -149,7 +158,7 @@ class TestMsgResetDeviceT2:
|
||||
# mnemonic phrases
|
||||
btn_code = yield
|
||||
assert btn_code == B.ResetDevice
|
||||
mnemonic = read_and_confirm_mnemonic(client.debug, words=12)
|
||||
mnemonic = read_and_confirm_mnemonic(client.debug, words=24)
|
||||
|
||||
# confirm recovery seed check
|
||||
btn_code = yield
|
||||
|
@ -32,13 +32,11 @@ from ..common import (
|
||||
read_and_confirm_mnemonic,
|
||||
)
|
||||
|
||||
STRENGTH_TO_WORDS = {128: 20, 256: 33}
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
class TestMsgResetDeviceT2:
|
||||
# TODO: test with different options
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_slip39_basic(self, client):
|
||||
strength = 128
|
||||
|
||||
def reset_device(client, strength):
|
||||
words = STRENGTH_TO_WORDS[strength]
|
||||
member_threshold = 3
|
||||
all_mnemonics = []
|
||||
|
||||
@ -58,7 +56,7 @@ class TestMsgResetDeviceT2:
|
||||
# mnemonic phrases
|
||||
btn_code = yield
|
||||
assert btn_code == B.ResetDevice
|
||||
mnemonic = read_and_confirm_mnemonic(client.debug, words=20)
|
||||
mnemonic = read_and_confirm_mnemonic(client.debug, words=words)
|
||||
all_mnemonics.append(mnemonic)
|
||||
|
||||
# Confirm continue to next share
|
||||
@ -132,6 +130,17 @@ class TestMsgResetDeviceT2:
|
||||
device.backup(client)
|
||||
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
class TestMsgResetDeviceT2:
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_slip39_basic(self, client):
|
||||
reset_device(client, 128)
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_reset_device_slip39_basic_256(self, client):
|
||||
reset_device(client, 256)
|
||||
|
||||
|
||||
def validate_mnemonics(mnemonics, threshold, expected_ems):
|
||||
# We expect these combinations to recreate the secret properly
|
||||
for test_group in combinations(mnemonics, threshold):
|
||||
|
@ -220,9 +220,11 @@
|
||||
"test_msg_resetdevice_bip39_t2.py-test_already_initialized": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
|
||||
"test_msg_resetdevice_bip39_t2.py-test_failed_pin": "f284b630fef6ae437c9726cd0ee0d1728a77f677f37cd5f88aabb21e596f589e",
|
||||
"test_msg_resetdevice_bip39_t2.py-test_reset_device": "aaa37f33897fbdf33858a9cbb8982be1b1c1d1e2cbff83ebfd4c49fa8fc4b342",
|
||||
"test_msg_resetdevice_bip39_t2.py-test_reset_device_pin": "8cf79b65a37d6680f351a203f32f49b41425531be77ddcc8db894959aada7cd9",
|
||||
"test_msg_resetdevice_bip39_t2.py-test_reset_device_192": "febbacc3370cf9219faa49bbc542a7aa1280d9fc3e6e9776dacbcd2f09231636",
|
||||
"test_msg_resetdevice_bip39_t2.py-test_reset_device_pin": "dd95b1f1e7b496828314a4baf77f5f9f3aa54fc11754236e35f7519da9fd44c8",
|
||||
"test_msg_resetdevice_slip39_advanced.py-test_reset_device_slip39_advanced": "b1ca19a20f4d2be96847c8d2373921a68c5c9bd1292790229c64f93a0319cb69",
|
||||
"test_msg_resetdevice_slip39_basic.py-test_reset_device_slip39_basic": "77e9d45a9fb16a8759478ac1d433bb86ce58c01fa135bc4524596955de20552d",
|
||||
"test_msg_resetdevice_slip39_basic.py-test_reset_device_slip39_basic_256": "5f21f628ada58d9b519aec96f99a087df1098825de33421ddb36777dc4f578f1",
|
||||
"test_msg_ripple_get_address.py-test_ripple_get_address": "2bb7d7bf48f1218530b4d7045d48480cad6411e110df537551b2f80b342007f2",
|
||||
"test_msg_ripple_get_address.py-test_ripple_get_address_other": "2bb7d7bf48f1218530b4d7045d48480cad6411e110df537551b2f80b342007f2",
|
||||
"test_msg_ripple_sign_tx.py-test_ripple_sign_invalid_fee": "1c0ca08b857da6121f43cfb1632c7f7e1d189ef1fdb665db7ba2cdfa7a59ea7c",
|
||||
|
Loading…
Reference in New Issue
Block a user