tests: update shamir tests for setup_client markers

pull/467/head
matejcik 5 years ago
parent 8e1d5374b1
commit 122f6c8085

@ -67,6 +67,7 @@ def enter_all_shares(debug, shares):
debug.press_yes()
@pytest.mark.setup_client(uninitialized=True)
def test_recover_no_pin_no_passphrase(client):
debug = client.debug
@ -89,6 +90,7 @@ def test_recover_no_pin_no_passphrase(client):
assert client.features.passphrase_protection is False
@pytest.mark.setup_client(uninitialized=True)
def test_abort(client):
debug = client.debug
@ -108,6 +110,7 @@ def test_abort(client):
assert client.features.initialized is False
@pytest.mark.setup_client(uninitialized=True)
def test_noabort(client):
debug = client.debug

@ -3,8 +3,6 @@ import pytest
from trezorlib import device, messages
from trezorlib.exceptions import TrezorFailure
from .conftest import setup_client
pytestmark = pytest.mark.skip_t1
SHARES_20_2of3_2of3_GROUPS = [
@ -23,7 +21,7 @@ INVALID_SHARES_20_2of3_2of3_GROUPS = [
]
@setup_client(mnemonic=SHARES_20_2of3_2of3_GROUPS[1:5], passphrase=False)
@pytest.mark.setup_client(mnemonic=SHARES_20_2of3_2of3_GROUPS[1:5], passphrase=False)
def test_2of3_dryrun(client):
debug = client.debug
@ -50,7 +48,7 @@ def test_2of3_dryrun(client):
)
@setup_client(mnemonic=SHARES_20_2of3_2of3_GROUPS[1:5], passphrase=True)
@pytest.mark.setup_client(mnemonic=SHARES_20_2of3_2of3_GROUPS[1:5], passphrase=True)
def test_2of3_invalid_seed_dryrun(client):
debug = client.debug

@ -14,7 +14,8 @@ EXTERNAL_ENTROPY = b"zlutoucky kun upel divoke ody" * 2
@pytest.mark.skip_t1
class TestMsgResetDeviceT2(TrezorTest):
# TODO: test with different options
def test_reset_device_supershamir(self):
@pytest.mark.setup_client(uninitialized=True)
def test_reset_device_supershamir(self, client):
strength = 128
member_threshold = 3
all_mnemonics = []
@ -23,53 +24,53 @@ class TestMsgResetDeviceT2(TrezorTest):
# Confirm Reset
btn_code = yield
assert btn_code == B.ResetDevice
self.client.debug.press_yes()
client.debug.press_yes()
# Backup your seed
btn_code = yield
assert btn_code == B.ResetDevice
self.client.debug.press_yes()
client.debug.press_yes()
# Confirm warning
btn_code = yield
assert btn_code == B.ResetDevice
self.client.debug.press_yes()
client.debug.press_yes()
# shares info
btn_code = yield
assert btn_code == B.ResetDevice
self.client.debug.press_yes()
client.debug.press_yes()
# Set & Confirm number of groups
btn_code = yield
assert btn_code == B.ResetDevice
self.client.debug.press_yes()
client.debug.press_yes()
# threshold info
btn_code = yield
assert btn_code == B.ResetDevice
self.client.debug.press_yes()
client.debug.press_yes()
# Set & confirm group threshold value
btn_code = yield
assert btn_code == B.ResetDevice
self.client.debug.press_yes()
client.debug.press_yes()
for _ in range(5):
# Set & Confirm number of share
btn_code = yield
assert btn_code == B.ResetDevice
self.client.debug.press_yes()
client.debug.press_yes()
# Set & confirm share threshold value
btn_code = yield
assert btn_code == B.ResetDevice
self.client.debug.press_yes()
client.debug.press_yes()
# Confirm show seeds
btn_code = yield
assert btn_code == B.ResetDevice
self.client.debug.press_yes()
client.debug.press_yes()
# show & confirm shares for all groups
for g in range(5):
@ -81,33 +82,33 @@ class TestMsgResetDeviceT2(TrezorTest):
# mnemonic phrases
# 20 word over 6 pages for strength 128, 33 words over 9 pages for strength 256
for i in range(6):
words.extend(self.client.debug.read_reset_word().split())
words.extend(client.debug.read_reset_word().split())
if i < 5:
self.client.debug.swipe_down()
client.debug.swipe_down()
else:
# last page is confirmation
self.client.debug.press_yes()
client.debug.press_yes()
# check share
for _ in range(3):
index = self.client.debug.read_reset_word_pos()
self.client.debug.input(words[index])
index = client.debug.read_reset_word_pos()
client.debug.input(words[index])
all_mnemonics.extend([" ".join(words)])
# Confirm continue to next share
btn_code = yield
assert btn_code == B.Success
self.client.debug.press_yes()
client.debug.press_yes()
# safety warning
btn_code = yield
assert btn_code == B.Success
self.client.debug.press_yes()
client.debug.press_yes()
os_urandom = mock.Mock(return_value=EXTERNAL_ENTROPY)
with mock.patch("os.urandom", os_urandom), self.client:
self.client.set_expected_responses(
with mock.patch("os.urandom", os_urandom), client:
client.set_expected_responses(
[
proto.ButtonRequest(code=B.ResetDevice),
proto.EntropyRequest(),
@ -193,11 +194,11 @@ class TestMsgResetDeviceT2(TrezorTest):
proto.Features(),
]
)
self.client.set_input_flow(input_flow)
client.set_input_flow(input_flow)
# No PIN, no passphrase, don't display random
device.reset(
self.client,
client,
display_random=False,
strength=strength,
passphrase_protection=False,
@ -208,17 +209,17 @@ class TestMsgResetDeviceT2(TrezorTest):
)
# generate secret locally
internal_entropy = self.client.debug.state().reset_entropy
internal_entropy = client.debug.state().reset_entropy
secret = generate_entropy(strength, internal_entropy, EXTERNAL_ENTROPY)
# validate that all combinations will result in the correct master secret
validate_mnemonics(all_mnemonics, member_threshold, secret)
# Check if device is properly initialized
assert self.client.features.initialized is True
assert self.client.features.needs_backup is False
assert self.client.features.pin_protection is False
assert self.client.features.passphrase_protection is False
assert client.features.initialized is True
assert client.features.needs_backup is False
assert client.features.pin_protection is False
assert client.features.passphrase_protection is False
def validate_mnemonics(mnemonics, threshold, expected_ems):

@ -6,6 +6,7 @@ from trezorlib.tools import parse_path
@pytest.mark.skip_t1
@pytest.mark.setup_client(uninitialized=True)
def test_reset_recovery(client):
mnemonics = reset(client)
address_before = btc.get_address(client, "Bitcoin", parse_path("44'/0'/0'/0/0"))

Loading…
Cancel
Save