Skip to content

Commit

Permalink
Tests: Fix deserialization of reject messages
Browse files Browse the repository at this point in the history
Assume that reject messages for blocks or transactions due to reason
REJECT_MALFORMED will not include the hash of the block or tx being rejected.
  • Loading branch information
sdaftuar committed Apr 20, 2016
1 parent 04a2937 commit 807fa47
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions qa/rpc-tests/test_framework/mininode.py
Expand Up @@ -983,6 +983,7 @@ def __repr__(self):

class msg_reject(object):
command = b"reject"
REJECT_MALFORMED = 1

def __init__(self):
self.message = b""
Expand All @@ -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

Expand Down

0 comments on commit 807fa47

Please sign in to comment.