mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 17:38:39 +00:00
Added TrezorClientDebug which prints wire messages to stdout
This commit is contained in:
parent
6e90d5763e
commit
2a3e5ace6b
4
cmd.py
4
cmd.py
@ -5,7 +5,7 @@ import argparse
|
||||
import json
|
||||
import base64
|
||||
|
||||
from trezorlib.client import TrezorClient
|
||||
from trezorlib.client import TrezorClientDebug
|
||||
from trezorlib.api_blockchain import BlockchainApi
|
||||
from trezorlib.protobuf_json import pb2json
|
||||
|
||||
@ -319,7 +319,7 @@ def main():
|
||||
return
|
||||
|
||||
transport = get_transport(args.transport, args.path)
|
||||
client = TrezorClient(transport)
|
||||
client = TrezorClientDebug(transport)
|
||||
client.set_tx_func(BlockchainApi().get_tx)
|
||||
cmds = Commands(client)
|
||||
|
||||
|
@ -63,13 +63,9 @@ class BaseClient(object):
|
||||
|
||||
def call_raw(self, msg):
|
||||
try:
|
||||
print "SENDING", pprint(msg)
|
||||
self.transport.session_begin()
|
||||
|
||||
self.transport.write(msg)
|
||||
resp = self.transport.read_blocking()
|
||||
print "RECEIVED", pprint(resp)
|
||||
|
||||
finally:
|
||||
self.transport.session_end()
|
||||
|
||||
@ -105,6 +101,13 @@ class BaseClient(object):
|
||||
def close(self):
|
||||
self.transport.close()
|
||||
|
||||
class DebugWireMixin(object):
|
||||
def call_raw(self, msg):
|
||||
print "SENDING", pprint(msg)
|
||||
resp = super(DebugWireMixin, self).call_raw(msg)
|
||||
print "RECEIVED", pprint(resp)
|
||||
return resp
|
||||
|
||||
class TextUIMixin(object):
|
||||
# This class demonstrates easy test-based UI
|
||||
# integration between the device and wallet.
|
||||
@ -179,9 +182,7 @@ class DebugLinkMixin(object):
|
||||
return resp
|
||||
|
||||
def call(self, msg):
|
||||
print "SENDING", pprint(msg)
|
||||
ret = super(DebugLinkMixin, self).call(msg)
|
||||
print "RECEIVED", pprint(ret)
|
||||
|
||||
if self.expected_responses != None and len(self.expected_responses):
|
||||
raise Exception("Some of expected responses didn't come from device: %s" % \
|
||||
@ -501,7 +502,10 @@ class ProtocolMixin(object):
|
||||
class TrezorClient(ProtocolMixin, TextUIMixin, BaseClient):
|
||||
pass
|
||||
|
||||
class TrezorDebugClient(ProtocolMixin, DebugLinkMixin, BaseClient):
|
||||
class TrezorClientDebug(ProtocolMixin, TextUIMixin, DebugWireMixin, BaseClient):
|
||||
pass
|
||||
|
||||
class TrezorDebugClient(ProtocolMixin, DebugLinkMixin, DebugWireMixin, BaseClient):
|
||||
pass
|
||||
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user