Permalink
Browse files

Merge #7912: Tests: Fix deserialization of reject messages

807fa47 Tests: Fix deserialization of reject messages (Suhas Daftuar)
  • Loading branch information...
MarcoFalke committed Apr 21, 2016
2 parents 78d61aa + 807fa47 commit 59ad56851a342d2c62f6b38bf15002b23ab439e1
Showing with 5 additions and 2 deletions.
  1. +5 −2 qa/rpc-tests/test_framework/mininode.py
@@ -983,6 +983,7 @@ def __repr__(self):
class msg_reject(object):
command = b"reject"
REJECT_MALFORMED = 1
def __init__(self):
self.message = b""
@@ -994,14 +995,16 @@ def deserialize(self, f):
self.message = deser_string(f)
self.code = struct.unpack("<B", f.read(1))[0]
self.reason = deser_string(f)
if (self.message == "block" or self.message == "tx"):
if (self.code != self.REJECT_MALFORMED and
(self.message == b"block" or self.message == b"tx")):
self.data = deser_uint256(f)
def serialize(self):
r = ser_string(self.message)
r += struct.pack("<B", self.code)
r += ser_string(self.reason)
if (self.message == "block" or self.message == "tx"):
if (self.code != self.REJECT_MALFORMED and
(self.message == b"block" or self.message == b"tx")):
r += ser_uint256(self.data)
return r

0 comments on commit 59ad568

Please sign in to comment.