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:
@ -4,12 +4,14 @@
|
||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
"""Test the wallet accounts properly when there are cloned transactions with malleated scriptsigs."""
|
||||
|
||||
import io
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
)
|
||||
from test_framework.messages import CTransaction, COIN
|
||||
from test_framework.messages import (
|
||||
COIN,
|
||||
tx_from_hex,
|
||||
)
|
||||
|
||||
|
||||
class TxnMallTest(BitcoinTestFramework):
|
||||
@ -71,8 +73,7 @@ class TxnMallTest(BitcoinTestFramework):
|
||||
clone_raw = self.nodes[0].createrawtransaction(clone_inputs, clone_outputs, clone_locktime)
|
||||
|
||||
# createrawtransaction randomizes the order of its outputs, so swap them if necessary.
|
||||
clone_tx = CTransaction()
|
||||
clone_tx.deserialize(io.BytesIO(bytes.fromhex(clone_raw)))
|
||||
clone_tx = tx_from_hex(clone_raw)
|
||||
if (rawtx1["vout"][0]["value"] == 40 and clone_tx.vout[0].nValue != 40*COIN or rawtx1["vout"][0]["value"] != 40 and clone_tx.vout[0].nValue == 40*COIN):
|
||||
(clone_tx.vout[0], clone_tx.vout[1]) = (clone_tx.vout[1], clone_tx.vout[0])
|
||||
|
||||
|
Reference in New Issue
Block a user