Skip to content

Commit 1914054

Browse files
theStackMarcoFalke
andcommitted
scripted-diff: test: rename FromHex to from_hex
-BEGIN VERIFY SCRIPT- sed -i 's/\<FromHex\>/from_hex/g' $(git grep -l FromHex) -END VERIFY SCRIPT- Co-authored-by: MarcoFalke <[email protected]>
1 parent a79396f commit 1914054

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

contrib/signet/miner

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PATH_BASE_TEST_FUNCTIONAL = os.path.abspath(os.path.join(PATH_BASE_CONTRIB_SIGNE
2323
sys.path.insert(0, PATH_BASE_TEST_FUNCTIONAL)
2424

2525
from test_framework.blocktools import WITNESS_COMMITMENT_HEADER, script_BIP34_coinbase_height # noqa: E402
26-
from test_framework.messages import CBlock, CBlockHeader, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, FromHex, deser_string, hash256, ser_compact_size, ser_string, ser_uint256, tx_from_hex, uint256_from_str # noqa: E402
26+
from test_framework.messages import CBlock, CBlockHeader, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, from_hex, deser_string, hash256, ser_compact_size, ser_string, ser_uint256, tx_from_hex, uint256_from_str # noqa: E402
2727
from test_framework.script import CScriptOp # noqa: E402
2828

2929
logging.basicConfig(
@@ -37,7 +37,7 @@ RE_MULTIMINER = re.compile("^(\d+)(-(\d+))?/(\d+)$")
3737

3838
# #### some helpers that could go into test_framework
3939

40-
# like FromHex, but without the hex part
40+
# like from_hex, but without the hex part
4141
def FromBinary(cls, stream):
4242
"""deserialize a binary stream (or bytes object) into an object"""
4343
# handle bytes object by turning it into a stream
@@ -195,7 +195,7 @@ def finish_block(block, signet_solution, grind_cmd):
195195
headhex = CBlockHeader.serialize(block).hex()
196196
cmd = grind_cmd.split(" ") + [headhex]
197197
newheadhex = subprocess.run(cmd, stdout=subprocess.PIPE, input=b"", check=True).stdout.strip()
198-
newhead = FromHex(CBlockHeader(), newheadhex.decode('utf8'))
198+
newhead = from_hex(CBlockHeader(), newheadhex.decode('utf8'))
199199
block.nNonce = newhead.nNonce
200200
block.rehash()
201201
return block

test/functional/feature_utxo_set_hash.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from test_framework.messages import (
1010
CBlock,
1111
COutPoint,
12-
FromHex,
12+
from_hex,
1313
)
1414
from test_framework.muhash import MuHash3072
1515
from test_framework.test_framework import BitcoinTestFramework
@@ -32,13 +32,13 @@ def test_muhash_implementation(self):
3232
# Generate 100 blocks and remove the first since we plan to spend its
3333
# coinbase
3434
block_hashes = wallet.generate(1) + node.generate(99)
35-
blocks = list(map(lambda block: FromHex(CBlock(), node.getblock(block, False)), block_hashes))
35+
blocks = list(map(lambda block: from_hex(CBlock(), node.getblock(block, False)), block_hashes))
3636
blocks.pop(0)
3737

3838
# Create a spending transaction and mine a block which includes it
3939
txid = wallet.send_self_transfer(from_node=node)['txid']
4040
tx_block = node.generateblock(output=wallet.get_address(), transactions=[txid])
41-
blocks.append(FromHex(CBlock(), node.getblock(tx_block['hash'], False)))
41+
blocks.append(from_hex(CBlock(), node.getblock(tx_block['hash'], False)))
4242

4343
# Serialize the outputs that should be in the UTXO set and add them to
4444
# a MuHash object

test/functional/p2p_compactblocks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
CTxIn,
2727
CTxInWitness,
2828
CTxOut,
29-
FromHex,
29+
from_hex,
3030
HeaderAndShortIDs,
3131
MSG_BLOCK,
3232
MSG_CMPCT_BLOCK,
@@ -321,7 +321,7 @@ def test_compactblock_construction(self, test_node, use_witness_address=True):
321321
block_hash = int(node.generate(1)[0], 16)
322322

323323
# Store the raw block in our internal format.
324-
block = FromHex(CBlock(), node.getblock("%064x" % block_hash, False))
324+
block = from_hex(CBlock(), node.getblock("%064x" % block_hash, False))
325325
for tx in block.vtx:
326326
tx.calc_sha256()
327327
block.rehash()
@@ -614,7 +614,7 @@ def test_getblocktxn_handler(self, test_node):
614614
current_height = chain_height
615615
while (current_height >= chain_height - MAX_GETBLOCKTXN_DEPTH):
616616
block_hash = node.getblockhash(current_height)
617-
block = FromHex(CBlock(), node.getblock(block_hash, False))
617+
block = from_hex(CBlock(), node.getblock(block_hash, False))
618618

619619
msg = msg_getblocktxn()
620620
msg.block_txn_request = BlockTransactionsRequest(int(block_hash, 16), [])

test/functional/p2p_dos_header_tree.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from test_framework.messages import (
88
CBlockHeader,
9-
FromHex,
9+
from_hex,
1010
)
1111
from test_framework.p2p import (
1212
P2PInterface,
@@ -42,8 +42,8 @@ def run_test(self):
4242
self.headers = [l for l in h_lines if not l.startswith(FORK_PREFIX)]
4343
self.headers_fork = [l[len(FORK_PREFIX):] for l in h_lines if l.startswith(FORK_PREFIX)]
4444

45-
self.headers = [FromHex(CBlockHeader(), h) for h in self.headers]
46-
self.headers_fork = [FromHex(CBlockHeader(), h) for h in self.headers_fork]
45+
self.headers = [from_hex(CBlockHeader(), h) for h in self.headers]
46+
self.headers_fork = [from_hex(CBlockHeader(), h) for h in self.headers_fork]
4747

4848
self.log.info("Feed all non-fork headers, including and up to the first checkpoint")
4949
peer_checkpoint = self.nodes[0].add_p2p_connection(P2PInterface())

test/functional/rpc_blockchain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
)
3232
from test_framework.messages import (
3333
CBlockHeader,
34-
FromHex,
34+
from_hex,
3535
msg_block,
3636
)
3737
from test_framework.p2p import P2PInterface
@@ -314,7 +314,7 @@ def _test_getblockheader(self):
314314
header_hex = node.getblockheader(blockhash=besthash, verbose=False)
315315
assert_is_hex_string(header_hex)
316316

317-
header = FromHex(CBlockHeader(), header_hex)
317+
header = from_hex(CBlockHeader(), header_hex)
318318
header.calc_sha256()
319319
assert_equal(header.hash, besthash)
320320

test/functional/rpc_txoutproof.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from test_framework.blocktools import COINBASE_MATURITY
88
from test_framework.messages import (
99
CMerkleBlock,
10-
FromHex,
10+
from_hex,
1111
)
1212
from test_framework.test_framework import BitcoinTestFramework
1313
from test_framework.util import (
@@ -94,7 +94,7 @@ def run_test(self):
9494
assert txid1 in self.nodes[0].verifytxoutproof(proof)
9595
assert txid2 in self.nodes[1].verifytxoutproof(proof)
9696

97-
tweaked_proof = FromHex(CMerkleBlock(), proof)
97+
tweaked_proof = from_hex(CMerkleBlock(), proof)
9898

9999
# Make sure that our serialization/deserialization is working
100100
assert txid1 in self.nodes[0].verifytxoutproof(tweaked_proof.serialize().hex())

test/functional/test_framework/messages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ def ser_string_vector(l):
191191

192192

193193
# Deserialize from a hex string representation (eg from RPC)
194-
def FromHex(obj, hex_string):
194+
def from_hex(obj, hex_string):
195195
obj.deserialize(BytesIO(hex_str_to_bytes(hex_string)))
196196
return obj
197197

198198

199199
def tx_from_hex(hex_string):
200200
"""Deserialize from hex string to a transaction object"""
201-
return FromHex(CTransaction(), hex_string)
201+
return from_hex(CTransaction(), hex_string)
202202

203203

204204
# Objects that map to bitcoind objects, which can be serialized/deserialized

0 commit comments

Comments
 (0)