Skip to content

Commit e3fe62b

Browse files
instagibbsstevenroose
authored andcommitted
Remove manual byte editing in wallet_tx_clone func test
1 parent 0c05901 commit e3fe62b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/functional/wallet_txn_clone.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
sync_blocks,
1515
hex_str_to_bytes,
1616
)
17+
from test_framework.messages import CTransaction, COIN
1718

1819
class TxnMallTest(BitcoinTestFramework):
1920
def set_test_params(self):
@@ -76,13 +77,13 @@ def run_test(self):
7677

7778
# createrawtransaction randomizes the order of its outputs, so swap them if necessary.
7879
clone_tx = CTransaction()
79-
clone_tx.deserialize(io.BytesIO(hex_str_to_bytes(clone_raw)))
80-
if (rawtx1["vout"][0]["value"] == 40 and clone_tx.vout[0].nValue != 40 or rawtx1["vout"][0]["value"] != 40 and clone_tx.vout[0].nValue == 40):
80+
clone_tx.deserialize(io.BytesIO(bytes.fromhex(clone_raw)))
81+
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):
8182
(clone_tx.vout[0], clone_tx.vout[1]) = (clone_tx.vout[1], clone_tx.vout[0])
8283

8384
# Use a different signature hash type to sign. This creates an equivalent but malleated clone.
8485
# Don't send the clone anywhere yet
85-
tx1_clone = self.nodes[0].signrawtransactionwithwallet(clone_raw, None, "ALL|ANYONECANPAY")
86+
tx1_clone = self.nodes[0].signrawtransactionwithwallet(clone_tx.serialize().hex(), None, "ALL|ANYONECANPAY")
8687
assert_equal(tx1_clone["complete"], True)
8788

8889
# Have node0 mine a block, if requested:

0 commit comments

Comments
 (0)