From 79664a4d08c4470e791384ad46858f4936cf5055 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 28 Feb 2019 12:45:09 +0100 Subject: [PATCH] burntest: add test for T1/T2 --- trezorlib/tests/burn_tests/burntest_t1.py | 75 +++++++++++++++++++ .../{burntest.py => burntest_t2.py} | 2 - 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100755 trezorlib/tests/burn_tests/burntest_t1.py rename trezorlib/tests/burn_tests/{burntest.py => burntest_t2.py} (97%) diff --git a/trezorlib/tests/burn_tests/burntest_t1.py b/trezorlib/tests/burn_tests/burntest_t1.py new file mode 100755 index 0000000000..c59782a2b0 --- /dev/null +++ b/trezorlib/tests/burn_tests/burntest_t1.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 + +# This file is part of the Trezor project. +# +# Copyright (C) 2012-2018 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 os +import random +import string + +from trezorlib import device +from trezorlib.debuglink import TrezorClientDebugLink +from trezorlib.transport import enumerate_devices, get_transport + + +def get_device(): + path = os.environ.get("TREZOR_PATH") + if path: + return get_transport(path) + else: + devices = enumerate_devices() + for d in devices: + if hasattr(d, "find_debug"): + return d + raise RuntimeError("No debuggable device found") + + +def pin_input_flow(client, old_pin, new_pin): + # do you want to change pin? + yield + client.debug.press_yes() + if old_pin is not None: + # enter old pin + yield + client.debug.input(old_pin) + # enter new pin + yield + client.debug.input(new_pin) + # repeat new pin + yield + client.debug.input(new_pin) + + +if __name__ == "__main__": + wirelink = get_device() + client = TrezorClientDebugLink(wirelink) + client.open() + + i = 0 + + last_pin = None + + while True: + # set private field + device.apply_settings(client, auto_lock_delay_ms=(i % 10 + 10) * 1000) + + # set public field + label = "".join(random.choices(string.ascii_uppercase + string.digits, k=17)) + device.apply_settings(client, label=label) + assert client.features.label == label + + print("iteration %d" % i) + i = i + 1 diff --git a/trezorlib/tests/burn_tests/burntest.py b/trezorlib/tests/burn_tests/burntest_t2.py similarity index 97% rename from trezorlib/tests/burn_tests/burntest.py rename to trezorlib/tests/burn_tests/burntest_t2.py index d26417aaeb..3ed9b87a0d 100755 --- a/trezorlib/tests/burn_tests/burntest.py +++ b/trezorlib/tests/burn_tests/burntest_t2.py @@ -57,8 +57,6 @@ if __name__ == "__main__": wirelink = get_device() client = TrezorClientDebugLink(wirelink) client.open() - device.wipe(client) - device.reset(client, no_backup=True) i = 0