From 0e2bcd64e8dfe239b6afd6f3363e5f38f2895fac Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Mon, 20 Nov 2017 17:41:23 +0100 Subject: [PATCH] tests: o.address fix --- src/apps/wallet/sign_tx/signing.py | 10 +++++++--- .../test_apps.wallet.segwit.signtx.native_p2wpkh.py | 7 ++++--- .../test_apps.wallet.segwit.signtx.p2wpkh_in_p2sh.py | 12 +++++++----- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/apps/wallet/sign_tx/signing.py b/src/apps/wallet/sign_tx/signing.py index 47f8621762..f0598e9449 100644 --- a/src/apps/wallet/sign_tx/signing.py +++ b/src/apps/wallet/sign_tx/signing.py @@ -116,7 +116,7 @@ async def check_tx_fee(tx: SignTx, root): raise SigningError(FailureType.ActionCancelled, 'Total cancelled') - return h_first, tx_req, txo_bin, bip143, segwit, total_in, wallet_path + return h_first, bip143, segwit, total_in, wallet_path async def sign_tx(tx: SignTx, root): @@ -125,8 +125,7 @@ async def sign_tx(tx: SignTx, root): # Phase 1 - h_first, tx_req, txo_bin, bip143, segwit, authorized_in, wallet_path = \ - await check_tx_fee(tx, root) + h_first, bip143, segwit, authorized_in, wallet_path = await check_tx_fee(tx, root) # Phase 2 # - sign inputs @@ -135,6 +134,11 @@ async def sign_tx(tx: SignTx, root): coin = coins.by_name(tx.coin_name) tx_ser = TxRequestSerializedType() + txo_bin = TxOutputBinType() + tx_req = TxRequest() + tx_req.details = TxRequestDetailsType() + tx_req.serialized = None + for i_sign in range(tx.inputs_count): # hash of what we are signing with this input h_sign = HashWriter(sha256) diff --git a/tests/test_apps.wallet.segwit.signtx.native_p2wpkh.py b/tests/test_apps.wallet.segwit.signtx.native_p2wpkh.py index d56c24c099..d9370b43a0 100644 --- a/tests/test_apps.wallet.segwit.signtx.native_p2wpkh.py +++ b/tests/test_apps.wallet.segwit.signtx.native_p2wpkh.py @@ -44,7 +44,7 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase): address_n=None, # @todo ask honza about sanitizing ) out2 = TxOutputType( - address='tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu', + address='tb1q694ccp5qcc0udmfwgp692u2s2hjpq5h407urtu', script_type=OutputScriptType.PAYTOADDRESS, amount=12300000 - 11000 - 5000000, address_n=None, @@ -170,7 +170,8 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase): # returned serialized inp1 serialized_tx=unhexlify('010000000001018a44999c07bba32df1cacdc50987944e68e3205b4429438fdde35c76024614090000000000ffffffff'), )), - TxAck(tx=TransactionType(outputs=[out1])), + # the out has to be cloned not to send the same object which was modified + TxAck(tx=TransactionType(outputs=[TxOutputType(**out1.__dict__)])), TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=TxRequestSerializedType( # returned serialized out1 @@ -178,7 +179,7 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase): signature_index=None, signature=None, )), - TxAck(tx=TransactionType(outputs=[out2])), + TxAck(tx=TransactionType(outputs=[TxOutputType(**out2.__dict__)])), # segwit TxRequest(request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=TxRequestSerializedType( diff --git a/tests/test_apps.wallet.segwit.signtx.p2wpkh_in_p2sh.py b/tests/test_apps.wallet.segwit.signtx.p2wpkh_in_p2sh.py index 25ae38c445..83fe499e30 100644 --- a/tests/test_apps.wallet.segwit.signtx.p2wpkh_in_p2sh.py +++ b/tests/test_apps.wallet.segwit.signtx.p2wpkh_in_p2sh.py @@ -175,8 +175,9 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase): serialized_tx=unhexlify( '0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff'), )), - TxAck(tx=TransactionType(outputs=[out1])), - # here + # the out has to be cloned not to send the same object which was modified + TxAck(tx=TransactionType(outputs=[TxOutputType(**out1.__dict__)])), + TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=TxRequestSerializedType( # returned serialized out1 @@ -185,7 +186,7 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase): signature_index=None, signature=None, )), - TxAck(tx=TransactionType(outputs=[out2])), + TxAck(tx=TransactionType(outputs=[TxOutputType(**out2.__dict__)])), # segwit TxRequest(request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), @@ -284,7 +285,8 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase): serialized_tx=unhexlify( '0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff'), )), - TxAck(tx=TransactionType(outputs=[out1])), + # the out has to be cloned not to send the same object which was modified + TxAck(tx=TransactionType(outputs=[TxOutputType(**out1.__dict__)])), TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=TxRequestSerializedType( @@ -294,7 +296,7 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase): signature_index=None, signature=None, )), - TxAck(tx=TransactionType(outputs=[out2])), + TxAck(tx=TransactionType(outputs=[TxOutputType(**out2.__dict__)])), # segwit TxRequest(request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None),