diff options
author | Jonas Schnelli <dev@jonasschnelli.ch> | 2017-12-11 09:54:13 -1000 |
---|---|---|
committer | Jonas Schnelli <dev@jonasschnelli.ch> | 2018-02-09 19:56:11 +1100 |
commit | 158e1a6f0f51296f80fc55e4e3b7712128f7a68b (patch) | |
tree | 3e73e70ea5c92260d06ba111f097d417bb249720 /test/functional/test_framework/messages.py | |
parent | fa999affad115c09743f8b1f5812326c19753ba9 (diff) |
[QA] fix mininode CAddress ser/deser
Diffstat (limited to 'test/functional/test_framework/messages.py')
-rwxr-xr-x[-rw-r--r--] | test/functional/test_framework/messages.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index a54a0299c7..ca92c51d3e 100644..100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -181,19 +181,24 @@ def ToHex(obj): class CAddress(): def __init__(self): + self.time = 0 self.nServices = 1 self.pchReserved = b"\x00" * 10 + b"\xff" * 2 self.ip = "0.0.0.0" self.port = 0 - def deserialize(self, f): + def deserialize(self, f, with_time=True): + if with_time: + self.time = struct.unpack("<i", f.read(4))[0] self.nServices = struct.unpack("<Q", f.read(8))[0] self.pchReserved = f.read(12) self.ip = socket.inet_ntoa(f.read(4)) self.port = struct.unpack(">H", f.read(2))[0] - def serialize(self): + def serialize(self, with_time=True): r = b"" + if with_time: + r += struct.pack("<i", self.time) r += struct.pack("<Q", self.nServices) r += self.pchReserved r += socket.inet_aton(self.ip) @@ -853,11 +858,11 @@ class msg_version(): self.nServices = struct.unpack("<Q", f.read(8))[0] self.nTime = struct.unpack("<q", f.read(8))[0] self.addrTo = CAddress() - self.addrTo.deserialize(f) + self.addrTo.deserialize(f, False) if self.nVersion >= 106: self.addrFrom = CAddress() - self.addrFrom.deserialize(f) + self.addrFrom.deserialize(f, False) self.nNonce = struct.unpack("<Q", f.read(8))[0] self.strSubVer = deser_string(f) else: @@ -885,8 +890,8 @@ class msg_version(): r += struct.pack("<i", self.nVersion) r += struct.pack("<Q", self.nServices) r += struct.pack("<q", self.nTime) - r += self.addrTo.serialize() - r += self.addrFrom.serialize() + r += self.addrTo.serialize(False) + r += self.addrFrom.serialize(False) r += struct.pack("<Q", self.nNonce) r += ser_string(self.strSubVer) r += struct.pack("<i", self.nStartingHeight) |