diff options
author | Troy Giorshev <troygiorshev@gmail.com> | 2020-11-17 19:50:12 -0500 |
---|---|---|
committer | Jarol Rodriguez <jarolrod@tutanota.com> | 2021-03-23 19:57:17 -0400 |
commit | 39a9ec579f023ab262a1abd1f0c869be5b1f3f4d (patch) | |
tree | 75b719c278e2c3f3f6a526be14b4659381bb7f89 /test | |
parent | 47b99ab1a9e918022ea13f54765f5b4e6aad6140 (diff) |
Unconditionally check for fRelay field in test framework
There is a discrepancy in the implementation of our p2p protocol between
bitcoind and the testing framework. The fRelay field is an optional
field at the end of a version message as of protocol version 70001.
However, when deserializing a message in bitcoind, we don't check the
version to see if it should have an fRelay field or not. Instead we
unconditionally attempt to deserialize into the field.
This commit brings the testing framework in line with the implementation
in core.
This matters for a version message with the following fields:
Version = 60000
fRelay = 1
Bitcoind would deserialize this into a version message with
Version=60000 and fRelay=1, whereas (before this commit) our testing
framework would deserialize this into a version message with
Version=60000 and fRelay=0.
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/test_framework/messages.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index a18a9ec109..5a9736a7a3 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -1045,13 +1045,11 @@ class msg_version: self.nStartingHeight = struct.unpack("<i", f.read(4))[0] - if self.nVersion >= 70001: - # Relay field is optional for version 70001 onwards - try: - self.relay = struct.unpack("<b", f.read(1))[0] - except: - self.relay = 0 - else: + # Relay field is optional for version 70001 onwards + # But, unconditionally check it to match behaviour in bitcoind + try: + self.relay = struct.unpack("<b", f.read(1))[0] + except struct.error: self.relay = 0 def serialize(self): |