1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00

tests: Don't lock storage after setup if the mnemonic needs to be checked.

This commit is contained in:
Andrew Kozlik 2019-02-14 21:07:30 +01:00
parent 9a1e14d974
commit 1e89f7923d
3 changed files with 15 additions and 15 deletions

View File

@ -43,7 +43,7 @@ class TrezorTest:
def teardown_method(self, method):
self.client.close()
def _setup_mnemonic(self, mnemonic=None, pin="", passphrase=False):
def _setup_mnemonic(self, mnemonic=None, pin="", passphrase=False, lock=True):
if mnemonic is None:
mnemonic = TrezorTest.mnemonic12
debuglink.load_device_by_mnemonic(
@ -54,26 +54,26 @@ class TrezorTest:
label="test",
language="english",
)
if conftest.TREZOR_VERSION == 1:
if conftest.TREZOR_VERSION == 1 and lock:
# remove cached PIN (introduced via load_device)
self.client.clear_session()
if conftest.TREZOR_VERSION > 1 and passphrase:
device.apply_settings(self.client, passphrase_source=PASSPHRASE_ON_HOST)
def setup_mnemonic_allallall(self):
self._setup_mnemonic(mnemonic=TrezorTest.mnemonic_all)
def setup_mnemonic_allallall(self, lock=True):
self._setup_mnemonic(mnemonic=TrezorTest.mnemonic_all, lock=lock)
def setup_mnemonic_nopin_nopassphrase(self):
self._setup_mnemonic()
def setup_mnemonic_nopin_nopassphrase(self, lock=True):
self._setup_mnemonic(lock=lock)
def setup_mnemonic_nopin_passphrase(self):
self._setup_mnemonic(passphrase=True)
def setup_mnemonic_nopin_passphrase(self, lock=True):
self._setup_mnemonic(passphrase=True, lock=lock)
def setup_mnemonic_pin_nopassphrase(self):
self._setup_mnemonic(pin=TrezorTest.pin4)
def setup_mnemonic_pin_nopassphrase(self, lock=True):
self._setup_mnemonic(pin=TrezorTest.pin4, lock=lock)
def setup_mnemonic_pin_passphrase(self):
self._setup_mnemonic(pin=TrezorTest.pin4, passphrase=True)
def setup_mnemonic_pin_passphrase(self, lock=True):
self._setup_mnemonic(pin=TrezorTest.pin4, passphrase=True, lock=lock)
def generate_entropy(strength, internal_entropy, external_entropy):

View File

@ -28,7 +28,7 @@ class TestDebuglink(TrezorTest):
assert len(layout) == 1024
def test_mnemonic(self):
self.setup_mnemonic_nopin_nopassphrase()
self.setup_mnemonic_nopin_nopassphrase(lock=False)
mnemonic = self.client.debug.state().mnemonic
assert mnemonic == self.mnemonic12

View File

@ -24,7 +24,7 @@ from .common import TrezorTest
@pytest.mark.skip_t2
class TestDeviceLoad(TrezorTest):
def test_load_device_1(self):
self.setup_mnemonic_nopin_nopassphrase()
self.setup_mnemonic_nopin_nopassphrase(lock=False)
state = self.client.debug.state()
assert state.mnemonic == self.mnemonic12
assert state.pin is None
@ -34,7 +34,7 @@ class TestDeviceLoad(TrezorTest):
assert address == "1EfKbQupktEMXf4gujJ9kCFo83k1iMqwqK"
def test_load_device_2(self):
self.setup_mnemonic_pin_passphrase()
self.setup_mnemonic_pin_passphrase(lock=False)
self.client.set_passphrase("passphrase")
state = self.client.debug.state()
assert state.mnemonic == self.mnemonic12