mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-03 10:32:05 +00:00
python fixes, tests
This commit is contained in:
@@ -6,6 +6,7 @@ class BytesReader():
|
||||
|
||||
def read(self, n):
|
||||
if len(self.buf) < n:
|
||||
print "reader err: buf less than n"
|
||||
# TODO: exception
|
||||
return
|
||||
r = self.buf[:n]
|
||||
|
||||
@@ -77,9 +77,9 @@ class TMSPServer():
|
||||
ret_code = res
|
||||
res = None
|
||||
|
||||
print "called", req_type, "ret code:", ret_code
|
||||
if ret_code != 0:
|
||||
print "non-zero retcode:", ret_code
|
||||
return
|
||||
|
||||
if req_type in ("echo", "info"): # these dont return a ret code
|
||||
response += bytearray([resTypeByte]) + encode(res)
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
# the decoder works off a reader
|
||||
# the encoder returns bytearray
|
||||
|
||||
def hex2bytes(h):
|
||||
return bytearray(h.decode('hex'))
|
||||
|
||||
def bytes2hex(b):
|
||||
if type(b) in (str, unicode):
|
||||
return "".join([hex(ord(c))[2:].zfill(2) for c in b])
|
||||
|
||||
Reference in New Issue
Block a user