diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-11-03 12:04:03 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-11-03 12:25:55 +0100 |
commit | fa1dea19fc50db449386c9f969adc5ad327a0f0d (patch) | |
tree | 90b6e347c268199317a470380a27e4fe794bcb4f /test/functional/test_framework/blocktools.py | |
parent | fa762a3fd43e49f8572be69e9129cd9170855f76 (diff) | |
download | bitcoin-fa1dea19fc50db449386c9f969adc5ad327a0f0d.tar.xz |
test: Fix deser issue in create_block
Without the fix a hex-string can not be parsed:
File "./test/functional/test_framework/blocktools.py", line 82, in create_block
txo.deserialize(io.BytesIO(tx))
TypeError: a bytes-like object is required, not 'str'
Also, remove io import and repace it with our FromHex() helper
Diffstat (limited to 'test/functional/test_framework/blocktools.py')
-rw-r--r-- | test/functional/test_framework/blocktools.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py index 64bc7e0485..6b7214f03a 100644 --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -5,7 +5,6 @@ """Utilities for manipulating blocks and transactions.""" from binascii import a2b_hex -import io import struct import time import unittest @@ -45,7 +44,6 @@ from .script import ( hash160, ) from .util import assert_equal -from io import BytesIO WITNESS_SCALE_FACTOR = 4 MAX_BLOCK_SIGOPS = 20000 @@ -78,9 +76,7 @@ def create_block(hashprev=None, coinbase=None, ntime=None, *, version=None, tmpl if txlist: for tx in txlist: if not hasattr(tx, 'calc_sha256'): - txo = CTransaction() - txo.deserialize(io.BytesIO(tx)) - tx = txo + tx = FromHex(CTransaction(), tx) block.vtx.append(tx) block.hashMerkleRoot = block.calc_merkle_root() block.calc_sha256() @@ -166,8 +162,7 @@ def create_transaction(node, txid, to_address, *, amount): sign for the output that is being spent. """ raw_tx = create_raw_transaction(node, txid, to_address, amount=amount) - tx = CTransaction() - tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx))) + tx = FromHex(CTransaction(), raw_tx) return tx def create_raw_transaction(node, txid, to_address, *, amount): |