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:
Sebastian Falbesoner
2021-06-15 23:02:28 +02:00
parent 965e937434
commit 2ce7b47958
22 changed files with 257 additions and 152 deletions

View File

@ -8,13 +8,12 @@ Test transaction download behavior
from test_framework.messages import (
CInv,
CTransaction,
FromHex,
MSG_TX,
MSG_TYPE_MASK,
MSG_WTX,
msg_inv,
msg_notfound,
tx_from_hex,
)
from test_framework.p2p import (
P2PInterface,
@ -100,7 +99,7 @@ class TxDownloadTest(BitcoinTestFramework):
hexstring=tx,
privkeys=[self.nodes[0].get_deterministic_priv_key().key],
)['hex']
ctx = FromHex(CTransaction(), tx)
ctx = tx_from_hex(tx)
txid = int(ctx.rehash(), 16)
self.log.info(