mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-29 10:19:26 +02:00
test: introduce tx_from_hex
helper for tx deserialization
`FromHex` is mostly used for transactions, so we introduce a shortcut `tx_from_hex` for `FromHex(CTransaction, hex_str)`.
This commit is contained in:
@ -14,17 +14,23 @@ added in the future, they should try to follow the same convention and not
|
||||
make assumptions about execution order.
|
||||
"""
|
||||
from decimal import Decimal
|
||||
import io
|
||||
|
||||
from test_framework.blocktools import COINBASE_MATURITY
|
||||
from test_framework.blocktools import add_witness_commitment, create_block, create_coinbase, send_to_witness
|
||||
from test_framework.messages import BIP125_SEQUENCE_NUMBER, CTransaction
|
||||
from test_framework.blocktools import (
|
||||
COINBASE_MATURITY,
|
||||
add_witness_commitment,
|
||||
create_block,
|
||||
create_coinbase,
|
||||
send_to_witness,
|
||||
)
|
||||
from test_framework.messages import (
|
||||
BIP125_SEQUENCE_NUMBER,
|
||||
tx_from_hex,
|
||||
)
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_greater_than,
|
||||
assert_raises_rpc_error,
|
||||
hex_str_to_bytes,
|
||||
)
|
||||
|
||||
WALLET_PASSPHRASE = "test"
|
||||
@ -576,9 +582,7 @@ def spend_one_input(node, dest_address, change_size=Decimal("0.00049000")):
|
||||
|
||||
|
||||
def submit_block_with_tx(node, tx):
|
||||
ctx = CTransaction()
|
||||
ctx.deserialize(io.BytesIO(hex_str_to_bytes(tx)))
|
||||
|
||||
ctx = tx_from_hex(tx)
|
||||
tip = node.getbestblockhash()
|
||||
height = node.getblockcount() + 1
|
||||
block_time = node.getblockheader(tip)["mediantime"] + 1
|
||||
|
Reference in New Issue
Block a user