mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 09:53:47 +01:00
test: Remove struct.pack from almost all places
This commit is contained in:
parent
fa826db477
commit
fa52e13ee8
@ -29,7 +29,6 @@ These should be pasted into `src/chainparamsseeds.h`.
|
|||||||
|
|
||||||
from base64 import b32decode
|
from base64 import b32decode
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import struct
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -117,11 +116,11 @@ def ser_compact_size(l):
|
|||||||
if l < 253:
|
if l < 253:
|
||||||
r = l.to_bytes(1, "little")
|
r = l.to_bytes(1, "little")
|
||||||
elif l < 0x10000:
|
elif l < 0x10000:
|
||||||
r = struct.pack("<BH", 253, l)
|
r = (253).to_bytes(1, "little") + l.to_bytes(2, "little")
|
||||||
elif l < 0x100000000:
|
elif l < 0x100000000:
|
||||||
r = struct.pack("<BI", 254, l)
|
r = (254).to_bytes(1, "little") + l.to_bytes(4, "little")
|
||||||
else:
|
else:
|
||||||
r = struct.pack("<BQ", 255, l)
|
r = (255).to_bytes(1, "little") + l.to_bytes(8, "little")
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def bip155_serialize(spec):
|
def bip155_serialize(spec):
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import struct
|
|
||||||
|
|
||||||
from test_framework.messages import ser_uint256, hash256, MAGIC_BYTES
|
from test_framework.messages import ser_uint256, hash256, MAGIC_BYTES
|
||||||
from test_framework.netutil import ADDRMAN_NEW_BUCKET_COUNT, ADDRMAN_TRIED_BUCKET_COUNT, ADDRMAN_BUCKET_SIZE
|
from test_framework.netutil import ADDRMAN_NEW_BUCKET_COUNT, ADDRMAN_TRIED_BUCKET_COUNT, ADDRMAN_BUCKET_SIZE
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Test block processing."""
|
"""Test block processing."""
|
||||||
import copy
|
import copy
|
||||||
import struct
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from test_framework.blocktools import (
|
from test_framework.blocktools import (
|
||||||
@ -67,7 +66,7 @@ class CBrokenBlock(CBlock):
|
|||||||
def serialize(self, with_witness=False):
|
def serialize(self, with_witness=False):
|
||||||
r = b""
|
r = b""
|
||||||
r += super(CBlock, self).serialize()
|
r += super(CBlock, self).serialize()
|
||||||
r += struct.pack("<BQ", 255, len(self.vtx))
|
r += (255).to_bytes(1, "little") + len(self.vtx).to_bytes(8, "little")
|
||||||
for tx in self.vtx:
|
for tx in self.vtx:
|
||||||
if with_witness:
|
if with_witness:
|
||||||
r += tx.serialize_with_witness()
|
r += tx.serialize_with_witness()
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
"""Test segwit transactions and blocks on P2P network."""
|
"""Test segwit transactions and blocks on P2P network."""
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
import random
|
import random
|
||||||
import struct
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from test_framework.blocktools import (
|
from test_framework.blocktools import (
|
||||||
|
@ -8,7 +8,6 @@ This file is modified from python-bitcoinlib.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import struct
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from .key import TaggedHash, tweak_add_pubkey, compute_xonly_pubkey
|
from .key import TaggedHash, tweak_add_pubkey, compute_xonly_pubkey
|
||||||
|
Loading…
Reference in New Issue
Block a user