test: Normalize struct.pack format

* Add () around some int values
* Remove b-prefix from strings

This is needed for the scripted diff to work.
This commit is contained in:
MarcoFalke 2024-02-07 11:30:21 +01:00
parent ef09f535b7
commit faf3cd659a
No known key found for this signature in database
2 changed files with 8 additions and 8 deletions

View file

@ -29,14 +29,14 @@ def serialize_addrman(
INCOMPATIBILITY_BASE = 32
r = MAGIC_BYTES[net_magic]
r += struct.pack("B", format)
r += struct.pack("B", INCOMPATIBILITY_BASE + lowest_compatible)
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

View file

@ -58,9 +58,9 @@ class CScriptOp(int):
elif len(d) <= 0xff:
return b'\x4c' + bytes([len(d)]) + d # OP_PUSHDATA1
elif len(d) <= 0xffff:
return b'\x4d' + struct.pack(b'<H', len(d)) + d # OP_PUSHDATA2
return b'\x4d' + struct.pack('<H', len(d)) + d # OP_PUSHDATA2
elif len(d) <= 0xffffffff:
return b'\x4e' + struct.pack(b'<I', len(d)) + d # OP_PUSHDATA4
return b'\x4e' + struct.pack('<I', len(d)) + d # OP_PUSHDATA4
else:
raise ValueError("Data too long to encode in a PUSHDATA op")
@ -670,7 +670,7 @@ def LegacySignatureMsg(script, txTo, inIdx, hashtype):
txtmp.vin.append(tmp)
s = txtmp.serialize_without_witness()
s += struct.pack(b"<I", hashtype)
s += struct.pack("<I", hashtype)
return (s, None)