aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-12-12 17:57:00 +0100
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-01-29 11:09:35 +0100
commitfa3886b7c69cbbe564478f30bb2c35e9e6b1cffa (patch)
tree44d14ad1aa46084fcd21a336f0d893bff64b4579 /test/functional
parent5fbcc8f0560cce36abafb8467339276b7c0d62b6 (diff)
test: Treat msg_version.relay as unsigned
The C++ code treats bool as uint8_t, so the python tests should as well. This also allows to simplify the code, because converting an empty byte array to int gives int(0). >>> int.from_bytes(b'') 0
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/test_framework/messages.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
index d008cb39aa..1e15113d88 100755
--- a/test/functional/test_framework/messages.py
+++ b/test/functional/test_framework/messages.py
@@ -1132,10 +1132,7 @@ class msg_version:
# 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
+ self.relay = int.from_bytes(f.read(1), "little") # f.read(1) may return an empty b''
def serialize(self):
r = b""
@@ -1147,7 +1144,7 @@ class msg_version:
r += struct.pack("<Q", self.nNonce)
r += ser_string(self.strSubVer.encode('utf-8'))
r += struct.pack("<i", self.nStartingHeight)
- r += struct.pack("<b", self.relay)
+ r += self.relay.to_bytes(1, "little")
return r
def __repr__(self):