diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-01-24 17:13:06 -0500 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-01-24 17:08:22 -0500 |
commit | fa3745bda84d5b3a26fdf8af4ac44d6088e11eee (patch) | |
tree | 65cc2f927a3655cc2f390ce95f6029280dd702ad /test/functional/test_framework/mininode.py | |
parent | 003a47f804b1c66661fbe9a3ccef431d5e300282 (diff) |
qa: Add tests for invalid message headers
Diffstat (limited to 'test/functional/test_framework/mininode.py')
-rwxr-xr-x | test/functional/test_framework/mininode.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py index ca5734d67d..ac7cc068bd 100755 --- a/test/functional/test_framework/mininode.py +++ b/test/functional/test_framework/mininode.py @@ -118,7 +118,7 @@ class P2PConnection(asyncio.Protocol): # The initial message to send after the connection was made: self.on_connection_send_msg = None self.recvbuf = b"" - self.network = net + self.magic_bytes = MAGIC_BYTES[net] logger.debug('Connecting to Bitcoin Node: %s:%d' % (self.dstaddr, self.dstport)) loop = NetworkThread.network_event_loop @@ -170,7 +170,7 @@ class P2PConnection(asyncio.Protocol): while True: if len(self.recvbuf) < 4: return - if self.recvbuf[:4] != MAGIC_BYTES[self.network]: + if self.recvbuf[:4] != self.magic_bytes: raise ValueError("got garbage %s" % repr(self.recvbuf)) if len(self.recvbuf) < 4 + 12 + 4 + 4: return @@ -232,7 +232,7 @@ class P2PConnection(asyncio.Protocol): """Build a serialized P2P message""" command = message.command data = message.serialize() - tmsg = MAGIC_BYTES[self.network] + tmsg = self.magic_bytes tmsg += command tmsg += b"\x00" * (12 - len(command)) tmsg += struct.pack("<I", len(data)) |