Skip to content

Commit faf3cd6

Browse files
author
MarcoFalke
committed
test: Normalize struct.pack format
* Add () around some int values * Remove b-prefix from strings This is needed for the scripted diff to work.
1 parent ef09f53 commit faf3cd6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

test/functional/feature_addrman.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ def serialize_addrman(
2929
INCOMPATIBILITY_BASE = 32
3030
r = MAGIC_BYTES[net_magic]
3131
r += struct.pack("B", format)
32-
r += struct.pack("B", INCOMPATIBILITY_BASE + lowest_compatible)
32+
r += struct.pack("B", (INCOMPATIBILITY_BASE + lowest_compatible))
3333
r += ser_uint256(bucket_key)
34-
r += struct.pack("<i", len_new or len(new))
35-
r += struct.pack("<i", len_tried or len(tried))
34+
r += struct.pack("<i", (len_new or len(new)))
35+
r += struct.pack("<i", (len_tried or len(tried)))
3636
ADDRMAN_NEW_BUCKET_COUNT = 1 << 10
37-
r += struct.pack("<i", ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30))
37+
r += struct.pack("<i", (ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30)))
3838
for _ in range(ADDRMAN_NEW_BUCKET_COUNT):
39-
r += struct.pack("<i", 0)
39+
r += struct.pack("<i", (0))
4040
checksum = hash256(r)
4141
r += mock_checksum or checksum
4242
return r

test/functional/test_framework/script.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ def encode_op_pushdata(d):
5858
elif len(d) <= 0xff:
5959
return b'\x4c' + bytes([len(d)]) + d # OP_PUSHDATA1
6060
elif len(d) <= 0xffff:
61-
return b'\x4d' + struct.pack(b'<H', len(d)) + d # OP_PUSHDATA2
61+
return b'\x4d' + struct.pack('<H', len(d)) + d # OP_PUSHDATA2
6262
elif len(d) <= 0xffffffff:
63-
return b'\x4e' + struct.pack(b'<I', len(d)) + d # OP_PUSHDATA4
63+
return b'\x4e' + struct.pack('<I', len(d)) + d # OP_PUSHDATA4
6464
else:
6565
raise ValueError("Data too long to encode in a PUSHDATA op")
6666

@@ -670,7 +670,7 @@ def LegacySignatureMsg(script, txTo, inIdx, hashtype):
670670
txtmp.vin.append(tmp)
671671

672672
s = txtmp.serialize_without_witness()
673-
s += struct.pack(b"<I", hashtype)
673+
s += struct.pack("<I", hashtype)
674674

675675
return (s, None)
676676

0 commit comments

Comments
 (0)