From 7c0dfec2dd9998932d13dd183c3ce4b22bd5851b Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Sat, 16 Jul 2022 01:56:56 +0200 Subject: refactor: move `from_binary` helper from signet miner to test framework Can be easily reviewed with `--color-moved=dimmed-zebra`. --- contrib/signet/miner | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'contrib/signet/miner') 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""" -- cgit v1.2.3