From 5eb0cdf020aa6b9fe03d6d018fdeda7201487d99 Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Wed, 24 Jul 2019 17:20:54 +0200 Subject: [PATCH] tests: move shamir passphrase test to seperate file, add one more case --- .../test_msg_recoverydevice_shamir.py | 32 +-------- .../device_tests/test_shamir_passphrase.py | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+), 31 deletions(-) create mode 100644 python/trezorlib/tests/device_tests/test_shamir_passphrase.py diff --git a/python/trezorlib/tests/device_tests/test_msg_recoverydevice_shamir.py b/python/trezorlib/tests/device_tests/test_msg_recoverydevice_shamir.py index 585dff289..3be9a1d37 100644 --- a/python/trezorlib/tests/device_tests/test_msg_recoverydevice_shamir.py +++ b/python/trezorlib/tests/device_tests/test_msg_recoverydevice_shamir.py @@ -18,8 +18,7 @@ import time import pytest -from trezorlib import btc, device, messages as proto -from trezorlib.messages.PassphraseSourceType import HOST as PASSPHRASE_ON_HOST +from trezorlib import btc, messages as proto from .common import TrezorTest @@ -114,14 +113,6 @@ class TestMsgRecoveryDeviceShamir(TrezorTest): address = btc.get_address(self.client, "Bitcoin", []) assert address == "1G1MwH5sLVxKQ7yKYasfE5pxWaABLo7VK7" - # TODO: test passphrase in load_device - # # BIP32 Root Key for passphrase TREZOR - # # provided by Andrew, address calculated using T1 - # # xprv9s21ZrQH143K2pMWi8jrTawHaj16uKk4CSbvo4Zt61tcrmuUDMx2o1Byzcr3saXNGNvHP8zZgXVdJHsXVdzYFPavxvCyaGyGr1WkAYG83ce - # self.client.set_passphrase("TREZOR") - # address = btc.get_address(self.client, "Bitcoin", []) - # assert address == "18oZEMRWurCZW1FeK8sWYyXuWx2bFqEKyX" - def test_2of5_pin_passphrase(self): # 256 bits security, 2 of 5 mnemonics = [ @@ -205,27 +196,6 @@ class TestMsgRecoveryDeviceShamir(TrezorTest): assert self.client.features.pin_protection is True assert self.client.features.passphrase_protection is True - device.apply_settings(self.client, passphrase_source=PASSPHRASE_ON_HOST) - - # BIP32 Root Key for empty passphrase - # provided by Andrew, address calculated using T1 - # xprv9s21ZrQH143K2kP9RYJE5AFggTHLs8PbDaaTYtvh238THxDyXqyqQV6H1QpFr3aaQ7CFusFMYyGZ6VcK7aLADyCaCJrszovxtzVZmnRfca4 - address = btc.get_address(self.client, "Bitcoin", []) - assert address == "1BmqXKM8M1gWA4bgkbPeCtJruRnrY2qYKP" - - # hackish way to clear passphrase - # TODO: move this to another test file and test using load_device on a new session - self.client.state = None - self.client.init_device() - self.client.set_passphrase("TREZOR") - - # BIP32 Root Key for passphrase TREZOR - # provided by Andrew, address calculated using T1 - # xprv9s21ZrQH143K2o6EXEHpVy8TCYoMmkBnDCCESLdR2ieKwmcNG48ck2XJQY4waS7RUQcXqR9N7HnQbUVEDMWYyREdF1idQqxFHuCfK7fqFni - - address = btc.get_address(self.client, "Bitcoin", []) - assert address == "19Fjs9AvT13Y2Nx8GtoVfADmFWnccsPinQ" - def test_abort(self): ret = self.client.call_raw( proto.RecoveryDevice( diff --git a/python/trezorlib/tests/device_tests/test_shamir_passphrase.py b/python/trezorlib/tests/device_tests/test_shamir_passphrase.py new file mode 100644 index 000000000..6b89d22ca --- /dev/null +++ b/python/trezorlib/tests/device_tests/test_shamir_passphrase.py @@ -0,0 +1,68 @@ +# 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 . + + +import pytest + +from trezorlib import btc, device +from trezorlib.messages.PassphraseSourceType import HOST as PASSPHRASE_ON_HOST + +from .conftest import setup_client + + +@setup_client( + mnemonic=( + "extra extend academic bishop cricket bundle tofu goat apart victim enlarge program behavior permit course armed jerky faint language modern", + "extra extend academic acne away best indicate impact square oasis prospect painting voting guest either argue username racism enemy eclipse", + "extra extend academic arcade born dive legal hush gross briefing talent drug much home firefly toxic analysis idea umbrella slice", + ), + passphrase=True, +) +@pytest.mark.skip_t1 +def test_3of6_passphrase(client): + """ + BIP32 Root Key for passphrase TREZOR: + provided by Andrew, address calculated using T1 + xprv9s21ZrQH143K2pMWi8jrTawHaj16uKk4CSbvo4Zt61tcrmuUDMx2o1Byzcr3saXNGNvHP8zZgXVdJHsXVdzYFPavxvCyaGyGr1WkAYG83ce + """ + assert client.debug.read_passphrase_protection() is True + device.apply_settings(client, passphrase_source=PASSPHRASE_ON_HOST) + + client.set_passphrase("TREZOR") + address = btc.get_address(client, "Bitcoin", []) + assert address == "18oZEMRWurCZW1FeK8sWYyXuWx2bFqEKyX" + + +@setup_client( + mnemonic=( + "hobo romp academic axis august founder knife legal recover alien expect emphasis loan kitchen involve teacher capture rebuild trial numb spider forward ladle lying voter typical security quantity hawk legs idle leaves gasoline", + "hobo romp academic agency ancestor industry argue sister scene midst graduate profile numb paid headset airport daisy flame express scene usual welcome quick silent downtown oral critical step remove says rhythm venture aunt", + ), + passphrase=True, +) +@pytest.mark.skip_t1 +def test_2of5_passphrase(client): + """ + BIP32 Root Key for passphrase TREZOR: + provided by Andrew, address calculated using T1 + xprv9s21ZrQH143K2o6EXEHpVy8TCYoMmkBnDCCESLdR2ieKwmcNG48ck2XJQY4waS7RUQcXqR9N7HnQbUVEDMWYyREdF1idQqxFHuCfK7fqFni + """ + assert client.debug.read_passphrase_protection() is True + device.apply_settings(client, passphrase_source=PASSPHRASE_ON_HOST) + + client.set_passphrase("TREZOR") + address = btc.get_address(client, "Bitcoin", []) + assert address == "19Fjs9AvT13Y2Nx8GtoVfADmFWnccsPinQ"