aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_segwit.py
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-02-07 11:26:05 +0100
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-05-07 15:40:47 +0200
commitfa826db477a981b48bff53021f9695a5f6682dc0 (patch)
treed59bf15566475700a29b85317f8b9aabddc40e82 /test/functional/p2p_segwit.py
parentfaf2a975ad46799d075e3a70c699da0d8182aab9 (diff)
downloadbitcoin-fa826db477a981b48bff53021f9695a5f6682dc0.tar.xz
scripted-diff: test: Use int.to_bytes over struct packing
-BEGIN VERIFY SCRIPT- sed -i --regexp-extended 's!struct.pack\(.<?B., (.*)\)!\1.to_bytes(1, "little")!g' $( git grep -l struct.pack ) sed -i --regexp-extended 's!struct.pack\(.<I., (.*)\)!\1.to_bytes(4, "little")!g' $( git grep -l struct.pack ) sed -i --regexp-extended 's!struct.pack\(.<H., (.*)\)!\1.to_bytes(2, "little")!g' $( git grep -l struct.pack ) sed -i --regexp-extended 's!struct.pack\(.<i., (.*)\)!\1.to_bytes(4, "little", signed=True)!g' $( git grep -l struct.pack ) sed -i --regexp-extended 's!struct.pack\(.<q., (.*)\)!\1.to_bytes(8, "little", signed=True)!g' $( git grep -l struct.pack ) sed -i --regexp-extended 's!struct.pack\(.>H., (.*)\)!\1.to_bytes(2, "big")!g' $( git grep -l struct.pack ) -END VERIFY SCRIPT-
Diffstat (limited to 'test/functional/p2p_segwit.py')
-rwxr-xr-xtest/functional/p2p_segwit.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py
index 45bbd7f1c3..03a19be722 100755
--- a/test/functional/p2p_segwit.py
+++ b/test/functional/p2p_segwit.py
@@ -1165,16 +1165,16 @@ class SegWitTest(BitcoinTestFramework):
if not self.wit.is_null():
flags |= 1
r = b""
- r += struct.pack("<i", self.nVersion)
+ r += self.nVersion.to_bytes(4, "little", signed=True)
if flags:
dummy = []
r += ser_vector(dummy)
- r += struct.pack("<B", flags)
+ r += flags.to_bytes(1, "little")
r += ser_vector(self.vin)
r += ser_vector(self.vout)
if flags & 1:
r += self.wit.serialize()
- r += struct.pack("<I", self.nLockTime)
+ r += self.nLockTime.to_bytes(4, "little")
return r
tx2 = BrokenCTransaction()
@@ -1976,11 +1976,11 @@ class SegWitTest(BitcoinTestFramework):
def serialize_with_bogus_witness(tx):
flags = 3
r = b""
- r += struct.pack("<i", tx.nVersion)
+ r += tx.nVersion.to_bytes(4, "little", signed=True)
if flags:
dummy = []
r += ser_vector(dummy)
- r += struct.pack("<B", flags)
+ r += flags.to_bytes(1, "little")
r += ser_vector(tx.vin)
r += ser_vector(tx.vout)
if flags & 1:
@@ -1990,7 +1990,7 @@ class SegWitTest(BitcoinTestFramework):
for _ in range(len(tx.wit.vtxinwit), len(tx.vin)):
tx.wit.vtxinwit.append(CTxInWitness())
r += tx.wit.serialize()
- r += struct.pack("<I", tx.nLockTime)
+ r += tx.nLockTime.to_bytes(4, "little")
return r
class msg_bogus_tx(msg_tx):