[tests] Explicitly disallow support for p2p versions below 60001
The mininode module includes code to support p2p versions below 60001. However, the test_framework does not support versions of Bitcoin Core before V0.13.0. Remove code supporting p2p versions before 60001 (which has never been run).
This commit is contained in:
parent
3858aabbd0
commit
fb00c45c32
1 changed files with 26 additions and 42 deletions
|
@ -37,6 +37,7 @@ from threading import RLock, Thread
|
||||||
from test_framework.siphash import siphash256
|
from test_framework.siphash import siphash256
|
||||||
from test_framework.util import hex_str_to_bytes, bytes_to_hex_str, wait_until
|
from test_framework.util import hex_str_to_bytes, bytes_to_hex_str, wait_until
|
||||||
|
|
||||||
|
MIN_VERSION_SUPPORTED = 60001
|
||||||
MY_VERSION = 70014 # past bip-31 for ping/pong
|
MY_VERSION = 70014 # past bip-31 for ping/pong
|
||||||
MY_SUBVERSION = b"/python-mininode-tester:0.0.3/"
|
MY_SUBVERSION = b"/python-mininode-tester:0.0.3/"
|
||||||
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
|
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
|
||||||
|
@ -1423,11 +1424,8 @@ class NodeConnCB():
|
||||||
self.verack_received = True
|
self.verack_received = True
|
||||||
|
|
||||||
def on_version(self, conn, message):
|
def on_version(self, conn, message):
|
||||||
if message.nVersion >= 209:
|
assert message.nVersion >= MIN_VERSION_SUPPORTED, "Version {} received. Test framework only supports versions greater than {}".format(message.nVersion, MIN_VERSION_SUPPORTED)
|
||||||
conn.send_message(msg_verack())
|
conn.send_message(msg_verack())
|
||||||
conn.ver_send = min(MY_VERSION, message.nVersion)
|
|
||||||
if message.nVersion < 209:
|
|
||||||
conn.ver_recv = conn.ver_send
|
|
||||||
conn.nServices = message.nServices
|
conn.nServices = message.nServices
|
||||||
|
|
||||||
# Connection helper methods
|
# Connection helper methods
|
||||||
|
@ -1609,17 +1607,6 @@ class NodeConn(asyncore.dispatcher):
|
||||||
return
|
return
|
||||||
if self.recvbuf[:4] != self.MAGIC_BYTES[self.network]:
|
if self.recvbuf[:4] != self.MAGIC_BYTES[self.network]:
|
||||||
raise ValueError("got garbage %s" % repr(self.recvbuf))
|
raise ValueError("got garbage %s" % repr(self.recvbuf))
|
||||||
if self.ver_recv < 209:
|
|
||||||
if len(self.recvbuf) < 4 + 12 + 4:
|
|
||||||
return
|
|
||||||
command = self.recvbuf[4:4+12].split(b"\x00", 1)[0]
|
|
||||||
msglen = struct.unpack("<i", self.recvbuf[4+12:4+12+4])[0]
|
|
||||||
checksum = None
|
|
||||||
if len(self.recvbuf) < 4 + 12 + 4 + msglen:
|
|
||||||
return
|
|
||||||
msg = self.recvbuf[4+12+4:4+12+4+msglen]
|
|
||||||
self.recvbuf = self.recvbuf[4+12+4+msglen:]
|
|
||||||
else:
|
|
||||||
if len(self.recvbuf) < 4 + 12 + 4 + 4:
|
if len(self.recvbuf) < 4 + 12 + 4 + 4:
|
||||||
return
|
return
|
||||||
command = self.recvbuf[4:4+12].split(b"\x00", 1)[0]
|
command = self.recvbuf[4:4+12].split(b"\x00", 1)[0]
|
||||||
|
@ -1633,16 +1620,14 @@ class NodeConn(asyncore.dispatcher):
|
||||||
if checksum != h[:4]:
|
if checksum != h[:4]:
|
||||||
raise ValueError("got bad checksum " + repr(self.recvbuf))
|
raise ValueError("got bad checksum " + repr(self.recvbuf))
|
||||||
self.recvbuf = self.recvbuf[4+12+4+4+msglen:]
|
self.recvbuf = self.recvbuf[4+12+4+4+msglen:]
|
||||||
if command in self.messagemap:
|
if command not in self.messagemap:
|
||||||
|
raise ValueError("Received unknown command from %s:%d: '%s' %s" % (self.dstaddr, self.dstport, command, repr(msg)))
|
||||||
f = BytesIO(msg)
|
f = BytesIO(msg)
|
||||||
t = self.messagemap[command]()
|
t = self.messagemap[command]()
|
||||||
t.deserialize(f)
|
t.deserialize(f)
|
||||||
self.got_message(t)
|
self.got_message(t)
|
||||||
else:
|
|
||||||
logger.warning("Received unknown command from %s:%d: '%s' %s" % (self.dstaddr, self.dstport, command, repr(msg)))
|
|
||||||
raise ValueError("Unknown command: '%s'" % (command))
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception('got_data:', repr(e))
|
logger.exception('Error reading message:', repr(e))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def send_message(self, message, pushbuf=False):
|
def send_message(self, message, pushbuf=False):
|
||||||
|
@ -1655,7 +1640,6 @@ class NodeConn(asyncore.dispatcher):
|
||||||
tmsg += command
|
tmsg += command
|
||||||
tmsg += b"\x00" * (12 - len(command))
|
tmsg += b"\x00" * (12 - len(command))
|
||||||
tmsg += struct.pack("<I", len(data))
|
tmsg += struct.pack("<I", len(data))
|
||||||
if self.ver_send >= 209:
|
|
||||||
th = sha256(data)
|
th = sha256(data)
|
||||||
h = sha256(th)
|
h = sha256(th)
|
||||||
tmsg += h[:4]
|
tmsg += h[:4]
|
||||||
|
|
Loading…
Reference in a new issue