From a461853cf6759c5d7485d86e48074b585a3ffc47 Mon Sep 17 00:00:00 2001 From: matejcik Date: Thu, 23 Jul 2020 16:20:54 +0200 Subject: [PATCH] core/tests: fix bitcoin unit tests --- core/tests/test_apps.bitcoin.ownership_proof.py | 16 ++++++++-------- ...t_apps.bitcoin.segwit.bip143.native_p2wpkh.py | 4 ++-- ..._apps.bitcoin.segwit.bip143.p2wpkh_in_p2sh.py | 4 ++-- ...t_apps.bitcoin.segwit.signtx.native_p2wpkh.py | 8 ++++---- ...ps.bitcoin.segwit.signtx.native_p2wpkh_grs.py | 6 +++--- ..._apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh.py | 8 ++++---- ...s.bitcoin.segwit.signtx.p2wpkh_in_p2sh_grs.py | 6 +++--- .../test_apps.bitcoin.signtx.fee_threshold.py | 4 ++-- core/tests/test_apps.bitcoin.signtx.py | 4 ++-- core/tests/test_apps.bitcoin.signtx_grs.py | 4 ++-- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/core/tests/test_apps.bitcoin.ownership_proof.py b/core/tests/test_apps.bitcoin.ownership_proof.py index 66829fe964..3ed3152b34 100644 --- a/core/tests/test_apps.bitcoin.ownership_proof.py +++ b/core/tests/test_apps.bitcoin.ownership_proof.py @@ -5,7 +5,7 @@ from trezor.messages.MultisigRedeemScriptType import MultisigRedeemScriptType from trezor.messages.HDNodeType import HDNodeType from apps.common import coins -from apps.common.seed import Keychain +from apps.common.keychain import Keychain from apps.common.paths import HARDENED from apps.bitcoin import ownership, scripts from apps.bitcoin.addresses import address_p2wpkh, address_p2wpkh_in_p2sh, address_multisig_p2wsh, address_multisig_p2wsh_in_p2sh, address_multisig_p2sh @@ -17,7 +17,7 @@ class TestOwnershipProof(unittest.TestCase): def test_p2wpkh_gen_proof(self): coin = coins.by_name('Bitcoin') seed = bip39.seed(' '.join(['all'] * 12), '') - keychain = Keychain(seed, [[coin.curve_name, [84 | HARDENED]], ["slip21", [b"SLIP-0019"]]]) + keychain = Keychain(seed, coin.curve_name, [[84 | HARDENED]], [[b"SLIP-0019"]]) commitment_data = b"" node = keychain.derive([84 | HARDENED, 0 | HARDENED, 0 | HARDENED, 1, 0]) @@ -43,7 +43,7 @@ class TestOwnershipProof(unittest.TestCase): def test_p2wpkh_in_p2sh_gen_proof(self): coin = coins.by_name('Bitcoin') seed = bip39.seed(' '.join(['all'] * 12), '') - keychain = Keychain(seed, [[coin.curve_name, [49 | HARDENED]], ["slip21", [b"SLIP-0019"]]]) + keychain = Keychain(seed, coin.curve_name, [[49 | HARDENED]], [[b"SLIP-0019"]]) commitment_data = b"" node = keychain.derive([49 | HARDENED, 0 | HARDENED, 0 | HARDENED, 1, 0]) @@ -70,7 +70,7 @@ class TestOwnershipProof(unittest.TestCase): def test_p2pkh_gen_proof(self): coin = coins.by_name('Bitcoin') seed = bip39.seed(' '.join(['all'] * 12), 'TREZOR') - keychain = Keychain(seed, [[coin.curve_name, [44 | HARDENED]], ["slip21", [b"SLIP-0019"]]]) + keychain = Keychain(seed, coin.curve_name, [[44 | HARDENED]], [[b"SLIP-0019"]]) commitment_data = b"" node = keychain.derive([44 | HARDENED, 0 | HARDENED, 0 | HARDENED, 1, 0]) @@ -96,7 +96,7 @@ class TestOwnershipProof(unittest.TestCase): def test_p2wpkh_verify_proof(self): coin = coins.by_name('Bitcoin') seed = bip39.seed(' '.join(['all'] * 12), 'TREZOR') - keychain = Keychain(seed, [["slip21", [b"SLIP-0019"]]]) + keychain = Keychain(seed, coin.curve_name, [], [[b"SLIP-0019"]]) commitment_data = b"" # Proof for "all all ... all" seed without passphrase. @@ -107,7 +107,7 @@ class TestOwnershipProof(unittest.TestCase): def test_p2wsh_gen_proof(self): coin = coins.by_name('Bitcoin') seed = bip39.seed(' '.join(['all'] * 12), '') - keychain = Keychain(seed, [[coin.curve_name, [84 | HARDENED]], ["slip21", [b"SLIP-0019"]]]) + keychain = Keychain(seed, coin.curve_name, [[84 | HARDENED]], [[b"SLIP-0019"]]) commitment_data = b"TREZOR" nodes = [] @@ -167,7 +167,7 @@ class TestOwnershipProof(unittest.TestCase): def test_p2wsh_in_p2sh_gen_proof(self): coin = coins.by_name('Bitcoin') seed = bip39.seed(' '.join(['all'] * 12), '') - keychain = Keychain(seed, [[coin.curve_name, [49 | HARDENED]], ["slip21", [b"SLIP-0019"]]]) + keychain = Keychain(seed, coin.curve_name, [[49 | HARDENED]], [[b"SLIP-0019"]]) commitment_data = b"" nodes = [] @@ -241,7 +241,7 @@ class TestOwnershipProof(unittest.TestCase): def test_p2sh_gen_proof(self): coin = coins.by_name('Bitcoin') seed = bip39.seed(' '.join(['all'] * 12), '') - keychain = Keychain(seed, [[coin.curve_name, [48 | HARDENED]], ["slip21", [b"SLIP-0019"]]]) + keychain = Keychain(seed, coin.curve_name, [[48 | HARDENED]], [[b"SLIP-0019"]]) commitment_data = b"TREZOR" nodes = [] diff --git a/core/tests/test_apps.bitcoin.segwit.bip143.native_p2wpkh.py b/core/tests/test_apps.bitcoin.segwit.bip143.native_p2wpkh.py index 75f0d333d8..e3e4e97331 100644 --- a/core/tests/test_apps.bitcoin.segwit.bip143.native_p2wpkh.py +++ b/core/tests/test_apps.bitcoin.segwit.bip143.native_p2wpkh.py @@ -4,7 +4,7 @@ from apps.bitcoin.scripts import output_derive_script from apps.bitcoin.sign_tx.bitcoin import Bitcoin from apps.bitcoin.writers import get_tx_hash from apps.common import coins -from apps.common.seed import Keychain +from apps.common.keychain import Keychain from trezor.messages.SignTx import SignTx from trezor.messages.TxInputType import TxInputType from trezor.messages.TxOutputType import TxOutputType @@ -90,7 +90,7 @@ class TestSegwitBip143NativeP2WPKH(unittest.TestCase): script_pubkey = output_derive_script(txo.address, coin) bip143.hash143_add_output(txo_bin, script_pubkey) - keychain = Keychain(seed, [[coin.curve_name, []]]) + keychain = Keychain(seed, coin.curve_name, [[]]) node = keychain.derive(self.inp2.address_n) # test data public key hash diff --git a/core/tests/test_apps.bitcoin.segwit.bip143.p2wpkh_in_p2sh.py b/core/tests/test_apps.bitcoin.segwit.bip143.p2wpkh_in_p2sh.py index 7f8b6f0d68..65d7451ae5 100644 --- a/core/tests/test_apps.bitcoin.segwit.bip143.p2wpkh_in_p2sh.py +++ b/core/tests/test_apps.bitcoin.segwit.bip143.p2wpkh_in_p2sh.py @@ -4,7 +4,7 @@ from apps.bitcoin.scripts import output_derive_script from apps.bitcoin.sign_tx.bitcoin import Bitcoin from apps.bitcoin.writers import get_tx_hash from apps.common import coins -from apps.common.seed import Keychain +from apps.common.keychain import Keychain from trezor.messages.SignTx import SignTx from trezor.messages.TxInputType import TxInputType from trezor.messages.TxOutputType import TxOutputType @@ -76,7 +76,7 @@ class TestSegwitBip143(unittest.TestCase): script_pubkey = output_derive_script(txo.address, coin) bip143.hash143_add_output(txo_bin, script_pubkey) - keychain = Keychain(seed, [[coin.curve_name, []]]) + keychain = Keychain(seed, coin.curve_name, [[]]) node = keychain.derive(self.inp1.address_n) # test data public key hash diff --git a/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh.py b/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh.py index 14d639cba9..edcdd85e22 100644 --- a/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh.py +++ b/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh.py @@ -17,7 +17,7 @@ from trezor.messages import OutputScriptType from trezor import wire from apps.common import coins -from apps.common.seed import Keychain +from apps.common.keychain import Keychain from apps.bitcoin.keychain import get_namespaces_for_coin from apps.bitcoin.sign_tx import helpers, bitcoin @@ -145,7 +145,7 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase): ] ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoin.Bitcoin(tx, keychain, coin).signer() for request, response in chunks(messages, 2): res = signer.send(request) @@ -268,7 +268,7 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase): ] ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoin.Bitcoin(tx, keychain, coin).signer() for request, response in chunks(messages, 2): self.assertEqual(signer.send(request), response) @@ -338,7 +338,7 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase): ] ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoin.Bitcoin(tx, keychain, coin).signer() for request, response in chunks(messages, 2): if response is None: diff --git a/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh_grs.py b/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh_grs.py index d2a5084da1..a10552aa90 100644 --- a/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh_grs.py +++ b/core/tests/test_apps.bitcoin.segwit.signtx.native_p2wpkh_grs.py @@ -16,7 +16,7 @@ from trezor.messages import InputScriptType from trezor.messages import OutputScriptType from apps.common import coins -from apps.common.seed import Keychain +from apps.common.keychain import Keychain from apps.bitcoin.keychain import get_namespaces_for_coin from apps.bitcoin.sign_tx import bitcoinlike, helpers @@ -146,7 +146,7 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase): ] ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer() for request, response in chunks(messages, 2): self.assertEqual(signer.send(request), response) @@ -268,7 +268,7 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase): ] ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer() for request, response in chunks(messages, 2): self.assertEqual(signer.send(request), response) diff --git a/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh.py b/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh.py index 6de06fe80c..499b58b77e 100644 --- a/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh.py +++ b/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh.py @@ -17,7 +17,7 @@ from trezor.messages import OutputScriptType from trezor import wire from apps.common import coins -from apps.common.seed import Keychain +from apps.common.keychain import Keychain from apps.bitcoin.keychain import get_namespaces_for_coin from apps.bitcoin.sign_tx import bitcoin, helpers @@ -142,7 +142,7 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase): ] ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoin.Bitcoin(tx, keychain, coin).signer() for request, response in chunks(messages, 2): self.assertEqual(signer.send(request), response) @@ -272,7 +272,7 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase): ] ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoin.Bitcoin(tx, keychain, coin).signer() for request, response in chunks(messages, 2): self.assertEqual(signer.send(request), response) @@ -354,7 +354,7 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase): ] ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoin.Bitcoin(tx, keychain, coin).signer() i = 0 messages_count = int(len(messages) / 2) diff --git a/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh_grs.py b/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh_grs.py index 09dd5fe0d9..e8a4b0775c 100644 --- a/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh_grs.py +++ b/core/tests/test_apps.bitcoin.segwit.signtx.p2wpkh_in_p2sh_grs.py @@ -16,7 +16,7 @@ from trezor.messages import InputScriptType from trezor.messages import OutputScriptType from apps.common import coins -from apps.common.seed import Keychain +from apps.common.keychain import Keychain from apps.bitcoin.keychain import get_namespaces_for_coin from apps.bitcoin.sign_tx import bitcoinlike, helpers @@ -146,7 +146,7 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase): ] ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer() for request, response in chunks(messages, 2): self.assertEqual(signer.send(request), response) @@ -276,7 +276,7 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase): ] ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer() for request, response in chunks(messages, 2): self.assertEqual(signer.send(request), response) diff --git a/core/tests/test_apps.bitcoin.signtx.fee_threshold.py b/core/tests/test_apps.bitcoin.signtx.fee_threshold.py index 6bcfc3835d..f3fe636d0f 100644 --- a/core/tests/test_apps.bitcoin.signtx.fee_threshold.py +++ b/core/tests/test_apps.bitcoin.signtx.fee_threshold.py @@ -15,7 +15,7 @@ from trezor.messages.TxRequestSerializedType import TxRequestSerializedType from trezor.messages import OutputScriptType from apps.common import coins -from apps.common.seed import Keychain +from apps.common.keychain import Keychain from apps.bitcoin.sign_tx import bitcoin, helpers @@ -161,7 +161,7 @@ class TestSignTxFeeThreshold(unittest.TestCase): seed = bip39.seed('alcohol woman abuse must during monitor noble actual mixed trade anger aisle', '') - keychain = Keychain(seed, [[coin_bitcoin.curve_name]]) + keychain = Keychain(seed, coin_bitcoin.curve_name, [[]]) signer = bitcoin.Bitcoin(tx, keychain, coin_bitcoin).signer() for request, response in chunks(messages, 2): res = signer.send(request) diff --git a/core/tests/test_apps.bitcoin.signtx.py b/core/tests/test_apps.bitcoin.signtx.py index 4fad0d0d34..e78a7434b9 100644 --- a/core/tests/test_apps.bitcoin.signtx.py +++ b/core/tests/test_apps.bitcoin.signtx.py @@ -15,7 +15,7 @@ from trezor.messages.TxRequestSerializedType import TxRequestSerializedType from trezor.messages import OutputScriptType from apps.common import coins -from apps.common.seed import Keychain +from apps.common.keychain import Keychain from apps.bitcoin.keychain import get_namespaces_for_coin from apps.bitcoin.sign_tx import bitcoin, helpers @@ -99,7 +99,7 @@ class TestSignTx(unittest.TestCase): seed = bip39.seed('alcohol woman abuse must during monitor noble actual mixed trade anger aisle', '') ns = get_namespaces_for_coin(coin_bitcoin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin_bitcoin.curve_name, ns) signer = bitcoin.Bitcoin(tx, keychain, coin_bitcoin).signer() for request, response in chunks(messages, 2): diff --git a/core/tests/test_apps.bitcoin.signtx_grs.py b/core/tests/test_apps.bitcoin.signtx_grs.py index 1ea30e2817..852fdf7ee7 100644 --- a/core/tests/test_apps.bitcoin.signtx_grs.py +++ b/core/tests/test_apps.bitcoin.signtx_grs.py @@ -15,7 +15,7 @@ from trezor.messages.TxRequestSerializedType import TxRequestSerializedType from trezor.messages import OutputScriptType from apps.common import coins -from apps.common.seed import Keychain +from apps.common.keychain import Keychain from apps.bitcoin.keychain import get_namespaces_for_coin from apps.bitcoin.sign_tx import bitcoinlike, helpers @@ -95,7 +95,7 @@ class TestSignTx_GRS(unittest.TestCase): seed = bip39.seed(' '.join(['all'] * 12), '') ns = get_namespaces_for_coin(coin) - keychain = Keychain(seed, ns) + keychain = Keychain(seed, coin.curve_name, ns) signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer() for request, response in chunks(messages, 2): self.assertEqual(signer.send(request), response)