diff options
author | fanquake <fanquake@gmail.com> | 2023-07-26 09:37:14 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-07-26 09:42:20 +0100 |
commit | 8fba5dfc1029c1b686b16bd68b3b18c1576f6058 (patch) | |
tree | 254e620fb036b420dc0974d00777ca048fbec54f /test/functional/feature_addrman.py | |
parent | 95d523fabb44637c17f838d9910952031de84545 (diff) | |
parent | 53c990ad3406ee945305af84af98d2f020e5f316 (diff) | |
download | bitcoin-8fba5dfc1029c1b686b16bd68b3b18c1576f6058.tar.xz |
Merge bitcoin/bitcoin#27529: test: fix `feature_addrman.py` on big-endian systems
53c990ad3406ee945305af84af98d2f020e5f316 test: fix `feature_addrman.py` on big-endian systems (Sebastian Falbesoner)
Pull request description:
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 (our internal (de)serializers always use little-endian, see `ser_{read,write}data32`). Fix this by explicitly specifying little-endian serialization via the `<` character in `struct.pack(...)`.
This is not detected by CI as we unfortunately don't run functional tests on big-endian systems there (I think we definitely should!).
ACKs for top commit:
MarcoFalke:
lgtm ACK 53c990ad3406ee945305af84af98d2f020e5f316 🔚
Tree-SHA512: 513af6f1f785a713e7a8ef3a57fcd3fe2520a7d537f63a9c8e1f4bdea4c2f605fd4c35001623d6b13458883dbc256f24943684ab8f224055c22bf8d8eeee5fe2
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 7877f9d302..d901b7bcf9 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 |