Skip to content

Commit 39a9ec5

Browse files
troygiorshevjarolrod
authored andcommitted
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.
1 parent 47b99ab commit 39a9ec5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

test/functional/test_framework/messages.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,13 +1045,11 @@ def deserialize(self, f):
10451045

10461046
self.nStartingHeight = struct.unpack("<i", f.read(4))[0]
10471047

1048-
if self.nVersion >= 70001:
1049-
# Relay field is optional for version 70001 onwards
1050-
try:
1051-
self.relay = struct.unpack("<b", f.read(1))[0]
1052-
except:
1053-
self.relay = 0
1054-
else:
1048+
# Relay field is optional for version 70001 onwards
1049+
# But, unconditionally check it to match behaviour in bitcoind
1050+
try:
1051+
self.relay = struct.unpack("<b", f.read(1))[0]
1052+
except struct.error:
10551053
self.relay = 0
10561054

10571055
def serialize(self):

0 commit comments

Comments
 (0)