From 5ffc2a1d7f4bcdffb780dc57ad1640316c86bec5 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 8 May 2017 22:15:24 +0200 Subject: [PATCH] tests: split xprv loading into separate test --- tests/device_tests/test_msg_loaddevice.py | 20 -------- .../device_tests/test_msg_loaddevice_xprv.py | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 tests/device_tests/test_msg_loaddevice_xprv.py diff --git a/tests/device_tests/test_msg_loaddevice.py b/tests/device_tests/test_msg_loaddevice.py index 6ade5304c..d8a6b4005 100644 --- a/tests/device_tests/test_msg_loaddevice.py +++ b/tests/device_tests/test_msg_loaddevice.py @@ -54,26 +54,6 @@ class TestDeviceLoad(common.TrezorTest): address = self.client.get_address('Bitcoin', []) self.assertEqual(address, '15fiTDFwZd2kauHYYseifGi9daH2wniDHH') - def test_load_device_3(self): - self.client.load_device_by_xprv(xprv='xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8imbZKLYVBxFPND1pniTZ81vKfd45EHKX73', pin='', passphrase_protection=False, label='test', language='english') - - passphrase_protection = self.client.debug.read_passphrase_protection() - self.assertEqual(passphrase_protection, False) - - address = self.client.get_address('Bitcoin', []) - self.assertEqual(address, '128RdrAkJDmqasgvfRf6MC5VcX4HKqH4mR') - - def test_load_device_4(self): - self.client.load_device_by_xprv(xprv='xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8imbZKLYVBxFPND1pniTZ81vKfd45EHKX73', pin='', passphrase_protection=True, label='test', language='english') - - self.client.set_passphrase('passphrase') - - passphrase_protection = self.client.debug.read_passphrase_protection() - self.assertEqual(passphrase_protection, True) - - address = self.client.get_address('Bitcoin', []) - self.assertEqual(address, '1CHUbFa4wTTPYgkYaw2LHSd5D4qJjMU8ri') - def test_load_device_utf(self): words_nfkd = u'Pr\u030ci\u0301s\u030cerne\u030c z\u030clut\u030couc\u030cky\u0301 ku\u030an\u030c u\u0301pe\u030cl d\u030ca\u0301belske\u0301 o\u0301dy za\u0301ker\u030cny\u0301 uc\u030cen\u030c be\u030cz\u030ci\u0301 pode\u0301l zo\u0301ny u\u0301lu\u030a' words_nfc = u'P\u0159\xed\u0161ern\u011b \u017elu\u0165ou\u010dk\xfd k\u016f\u0148 \xfap\u011bl \u010f\xe1belsk\xe9 \xf3dy z\xe1ke\u0159n\xfd u\u010de\u0148 b\u011b\u017e\xed pod\xe9l z\xf3ny \xfal\u016f' diff --git a/tests/device_tests/test_msg_loaddevice_xprv.py b/tests/device_tests/test_msg_loaddevice_xprv.py new file mode 100644 index 000000000..cc76c6875 --- /dev/null +++ b/tests/device_tests/test_msg_loaddevice_xprv.py @@ -0,0 +1,47 @@ +# This file is part of the TREZOR project. +# +# Copyright (C) 2012-2016 Marek Palatinus +# Copyright (C) 2012-2016 Pavol Rusnak +# +# This library is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# 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 GNU Lesser General Public License +# along with this library. If not, see . + +import unittest +import common + +from trezorlib import messages_pb2 as messages + +class TestDeviceLoadXprv(common.TrezorTest): + + def test_load_device_xprv_1(self): + self.client.load_device_by_xprv(xprv='xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8imbZKLYVBxFPND1pniTZ81vKfd45EHKX73', pin='', passphrase_protection=False, label='test', language='english') + + passphrase_protection = self.client.debug.read_passphrase_protection() + self.assertEqual(passphrase_protection, False) + + address = self.client.get_address('Bitcoin', []) + self.assertEqual(address, '128RdrAkJDmqasgvfRf6MC5VcX4HKqH4mR') + + def test_load_device_xprv_2(self): + self.client.load_device_by_xprv(xprv='xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8imbZKLYVBxFPND1pniTZ81vKfd45EHKX73', pin='', passphrase_protection=True, label='test', language='english') + + self.client.set_passphrase('passphrase') + + passphrase_protection = self.client.debug.read_passphrase_protection() + self.assertEqual(passphrase_protection, True) + + address = self.client.get_address('Bitcoin', []) + self.assertEqual(address, '1CHUbFa4wTTPYgkYaw2LHSd5D4qJjMU8ri') + +if __name__ == '__main__': + unittest.main()