aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2022-07-16 01:56:56 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2022-07-19 15:40:51 +0200
commit7c0dfec2dd9998932d13dd183c3ce4b22bd5851b (patch)
tree4924be6c5d5e2860c6366ff33d536fca2b320e57 /contrib
parent597a4b35f6e11d0ec5181e0d4d2d8f9bbf59898a (diff)
downloadbitcoin-7c0dfec2dd9998932d13dd183c3ce4b22bd5851b.tar.xz
refactor: move `from_binary` helper from signet miner to test framework
Can be easily reviewed with `--color-moved=dimmed-zebra`.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/signet/miner17
1 files changed, 1 insertions, 16 deletions
diff --git a/contrib/signet/miner b/contrib/signet/miner
index 7329b02b4a..841de01ee5 100755
--- a/contrib/signet/miner
+++ b/contrib/signet/miner
@@ -15,14 +15,12 @@ import sys
import time
import subprocess
-from io import BytesIO
-
PATH_BASE_CONTRIB_SIGNET = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
PATH_BASE_TEST_FUNCTIONAL = os.path.abspath(os.path.join(PATH_BASE_CONTRIB_SIGNET, "..", "..", "test", "functional"))
sys.path.insert(0, PATH_BASE_TEST_FUNCTIONAL)
from test_framework.blocktools import get_witness_script, script_BIP34_coinbase_height # noqa: E402
-from test_framework.messages import CBlock, CBlockHeader, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, from_hex, deser_string, ser_compact_size, ser_string, ser_uint256, tx_from_hex # noqa: E402
+from test_framework.messages import CBlock, CBlockHeader, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, from_binary, from_hex, deser_string, ser_compact_size, ser_string, ser_uint256, tx_from_hex # noqa: E402
from test_framework.script import CScriptOp # noqa: E402
logging.basicConfig(
@@ -36,19 +34,6 @@ RE_MULTIMINER = re.compile("^(\d+)(-(\d+))?/(\d+)$")
# #### some helpers that could go into test_framework
-# like from_hex, but without the hex part
-def from_binary(cls, stream):
- """deserialize a binary stream (or bytes object) into an object"""
- # handle bytes object by turning it into a stream
- was_bytes = isinstance(stream, bytes)
- if was_bytes:
- stream = BytesIO(stream)
- obj = cls()
- obj.deserialize(stream)
- if was_bytes:
- assert len(stream.read()) == 0
- return obj
-
class PSBTMap:
"""Class for serializing and deserializing PSBT maps"""