From a19f35747d19c9624a0915d82959b1fd7f8a3b50 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 29 Jan 2019 16:52:30 +0100 Subject: [PATCH] tests: add first burntest --- trezorlib/tests/burn_tests/test_burntest.py | 61 +++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 trezorlib/tests/burn_tests/test_burntest.py diff --git a/trezorlib/tests/burn_tests/test_burntest.py b/trezorlib/tests/burn_tests/test_burntest.py new file mode 100755 index 0000000000..e8d3d171ef --- /dev/null +++ b/trezorlib/tests/burn_tests/test_burntest.py @@ -0,0 +1,61 @@ +#!/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 debuglink, 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 device in devices: + if hasattr(device, "find_debug"): + return device + raise RuntimeError("No debuggable device found") + + +wirelink = get_device() +client = TrezorClientDebugLink(wirelink) +client.open() +device.wipe(client) +device.reset(client, no_backup=True) + +i = 0 + +while True: + # set private field + device.apply_settings(client, use_passphrase=True) + assert client.features.passphrase_protection == True + device.apply_settings(client, use_passphrase=False) + assert client.features.passphrase_protection == False + + # 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