core/tests: fix bitcoin unit tests

pull/1140/head
matejcik 4 years ago committed by matejcik
parent e3bb39128d
commit a461853cf6

@ -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 = []

@ -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

@ -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

@ -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:

@ -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)

@ -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)

@ -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)

@ -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)

@ -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):

@ -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)

Loading…
Cancel
Save