diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-04-25 08:19:50 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-04-25 08:39:13 +0200 |
commit | 53c990ad3406ee945305af84af98d2f020e5f316 (patch) | |
tree | 51352a43a56195e9cbcd6aa129b8718b8bff4441 /test/functional/feature_addrman.py | |
parent | 397ed22162f05fa7fb27c2e5f49f5917884b4716 (diff) |
test: fix `feature_addrman.py` on big-endian systems
The test `feature_addrman.py` currently serializes the addrdb without
specifying endianness for `int`s, so the machine's native byte order is used (see
https://docs.python.org/3/library/struct.html#byte-order-size-and-alignment)
and the generated `peers.dat` would be invalid on big-endian systems.
Fix this by explicitly specifying little-endian serialization via the
`<` character in `struct.pack(...)`.
Diffstat (limited to 'test/functional/feature_addrman.py')
-rwxr-xr-x | test/functional/feature_addrman.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/functional/feature_addrman.py b/test/functional/feature_addrman.py index 28c3880513..57a26b5030 100755 --- a/test/functional/feature_addrman.py +++ b/test/functional/feature_addrman.py @@ -32,12 +32,12 @@ def serialize_addrman( r += struct.pack("B", format) r += struct.pack("B", INCOMPATIBILITY_BASE + lowest_compatible) r += ser_uint256(bucket_key) - r += struct.pack("i", len_new or len(new)) - r += struct.pack("i", len_tried or len(tried)) + r += struct.pack("<i", len_new or len(new)) + r += struct.pack("<i", len_tried or len(tried)) ADDRMAN_NEW_BUCKET_COUNT = 1 << 10 - r += struct.pack("i", ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30)) + r += struct.pack("<i", ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30)) for _ in range(ADDRMAN_NEW_BUCKET_COUNT): - r += struct.pack("i", 0) + r += struct.pack("<i", 0) checksum = hash256(r) r += mock_checksum or checksum return r |