mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-11 15:48:05 +00:00
Tests: Fix deserialization of reject messages
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.
This commit is contained in:
parent
04a2937357
commit
807fa47a1e
@ -983,6 +983,7 @@ class msg_headers(object):
|
|||||||
|
|
||||||
class msg_reject(object):
|
class msg_reject(object):
|
||||||
command = b"reject"
|
command = b"reject"
|
||||||
|
REJECT_MALFORMED = 1
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.message = b""
|
self.message = b""
|
||||||
@ -994,14 +995,16 @@ class msg_reject(object):
|
|||||||
self.message = deser_string(f)
|
self.message = deser_string(f)
|
||||||
self.code = struct.unpack("<B", f.read(1))[0]
|
self.code = struct.unpack("<B", f.read(1))[0]
|
||||||
self.reason = deser_string(f)
|
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)
|
self.data = deser_uint256(f)
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
r = ser_string(self.message)
|
r = ser_string(self.message)
|
||||||
r += struct.pack("<B", self.code)
|
r += struct.pack("<B", self.code)
|
||||||
r += ser_string(self.reason)
|
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)
|
r += ser_uint256(self.data)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user