From 35f789122b2a8c721d623df3ad1ad27f3302446e Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 11 Nov 2016 18:57:59 +0100 Subject: [PATCH] tests: support v2 emulator in tests --- tests/config.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/config.py b/tests/config.py index a5c3661c8f..4829a07903 100644 --- a/tests/config.py +++ b/tests/config.py @@ -5,6 +5,15 @@ sys.path = ['../',] + sys.path from trezorlib.transport_pipe import PipeTransport from trezorlib.transport_hid import HidTransport +from trezorlib.transport_udp import UdpTransport + +def pipe_exists(path): + import os + try: + os.stat(path) + return True + except: + return False devices = HidTransport.enumerate() @@ -16,11 +25,21 @@ if len(devices) > 0: DEBUG_TRANSPORT = HidTransport DEBUG_TRANSPORT_ARGS = (devices[0],) DEBUG_TRANSPORT_KWARGS = {'debug_link': True} -else: - print('Using Emulator(v1)') + +elif pipe_exists('/tmp/pipe.trezor.to'): + print('Using Emulator (v1=pipe)') TRANSPORT = PipeTransport TRANSPORT_ARGS = ('/tmp/pipe.trezor', False) TRANSPORT_KWARGS = {} DEBUG_TRANSPORT = PipeTransport DEBUG_TRANSPORT_ARGS = ('/tmp/pipe.trezor_debug', False) DEBUG_TRANSPORT_KWARGS = {} + +elif True: + print('Using Emulator (v2=udp)') + TRANSPORT = UdpTransport + TRANSPORT_ARGS = ('127.0.0.1:21324') + TRANSPORT_KWARGS = {} + DEBUG_TRANSPORT = UdpTransport + DEBUG_TRANSPORT_ARGS = ('127.0.0.1:21324') + DEBUG_TRANSPORT_KWARGS = {}