1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-28 00:58:09 +00:00

core: fix unit tests for Bitcoin only firmware

This commit is contained in:
Pavol Rusnak 2019-08-26 18:47:49 +02:00
parent 908bbfffef
commit 32edf7b6b9
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
40 changed files with 284 additions and 188 deletions

View File

@ -5,3 +5,5 @@ sys.path.append('../src')
from ubinascii import hexlify, unhexlify # noqa: F401 from ubinascii import hexlify, unhexlify # noqa: F401
import unittest # noqa: F401 import unittest # noqa: F401
from trezor import utils # noqa: F401

View File

@ -1,10 +1,13 @@
from common import * from common import *
from apps.common.paths import HARDENED from apps.common.paths import HARDENED
from apps.binance.helpers import address_from_public_key, validate_full_path
from trezor.crypto.curve import secp256k1 from trezor.crypto.curve import secp256k1
from ubinascii import unhexlify
if not utils.BITCOIN_ONLY:
from apps.binance.helpers import address_from_public_key, validate_full_path
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestBinanceAddress(unittest.TestCase): class TestBinanceAddress(unittest.TestCase):
def test_privkey_to_address(self): def test_privkey_to_address(self):
#source of test data - binance javascript SDK #source of test data - binance javascript SDK

View File

@ -1,19 +1,21 @@
from common import * from common import *
from apps.binance.helpers import produce_json_for_signing
from apps.binance.sign_tx import generate_content_signature, sign_tx
from trezor.crypto.curve import secp256k1 from trezor.crypto.curve import secp256k1
from trezor.crypto.hashlib import sha256 from trezor.crypto.hashlib import sha256
from trezor.messages.BinanceCancelMsg import BinanceCancelMsg
from trezor.messages.BinanceCoin import BinanceCoin if not utils.BITCOIN_ONLY:
from trezor.messages.BinanceInputOutput import BinanceInputOutput from apps.binance.helpers import produce_json_for_signing
from trezor.messages.BinanceOrderMsg import BinanceOrderMsg from apps.binance.sign_tx import generate_content_signature, sign_tx
from trezor.messages.BinanceSignTx import BinanceSignTx from trezor.messages.BinanceCancelMsg import BinanceCancelMsg
from trezor.messages.BinanceTransferMsg import BinanceTransferMsg from trezor.messages.BinanceCoin import BinanceCoin
from trezor.messages.BinanceInputOutput import BinanceInputOutput
from trezor.messages.BinanceOrderMsg import BinanceOrderMsg
from trezor.messages.BinanceSignTx import BinanceSignTx
from trezor.messages.BinanceTransferMsg import BinanceTransferMsg
class TestBinanceSign(unittest.TestCase): @unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestBinanceSign(unittest.TestCase):
def test_order_signature(self): def test_order_signature(self):
# source of testing data # source of testing data
# https://github.com/binance-chain/javascript-sdk/blob/master/__tests__/fixtures/placeOrder.json # https://github.com/binance-chain/javascript-sdk/blob/master/__tests__/fixtures/placeOrder.json

View File

@ -2,16 +2,18 @@ from common import *
from apps.common import seed from apps.common import seed
from apps.common import HARDENED from apps.common import HARDENED
from apps.cardano.address import (
_get_address_root,
_address_hash,
validate_full_path,
derive_address_and_node
)
from apps.cardano.seed import Keychain
from trezor.crypto import bip32, slip39 from trezor.crypto import bip32, slip39
if not utils.BITCOIN_ONLY:
from apps.cardano.address import (
_get_address_root,
_address_hash,
validate_full_path,
derive_address_and_node
)
from apps.cardano.seed import Keychain
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestCardanoAddress(unittest.TestCase): class TestCardanoAddress(unittest.TestCase):
def test_hardened_address_derivation_scheme(self): def test_hardened_address_derivation_scheme(self):
mnemonic = "all all all all all all all all all all all all" mnemonic = "all all all all all all all all all all all all"

View File

@ -3,9 +3,9 @@ from common import *
from apps.cardano.seed import Keychain from apps.cardano.seed import Keychain
from apps.cardano.get_public_key import _get_public_key from apps.cardano.get_public_key import _get_public_key
from trezor.crypto import bip32, slip39 from trezor.crypto import bip32, slip39
from ubinascii import hexlify
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestCardanoGetPublicKey(unittest.TestCase): class TestCardanoGetPublicKey(unittest.TestCase):
def test_get_public_key_scheme(self): def test_get_public_key_scheme(self):
mnemonic = "all all all all all all all all all all all all" mnemonic = "all all all all all all all all all all all all"

View File

@ -6,7 +6,6 @@ from apps.common.cbor import (
decode, decode,
encode, encode,
) )
from ubinascii import unhexlify
class TestCardanoCbor(unittest.TestCase): class TestCardanoCbor(unittest.TestCase):
def test_cbor_encoding(self): def test_cbor_encoding(self):

View File

@ -5,9 +5,20 @@ from apps.common import coins
class TestCoins(unittest.TestCase): class TestCoins(unittest.TestCase):
def test_coins(self): def test_bitcoin(self):
ref = [ ref = [
('BTC', 'Bitcoin', 0), ('BTC', 'Bitcoin', 0),
('TEST', 'Testnet', 111),
('REGTEST', 'Regtest', 111),
]
for s, n, a in ref:
c = coins.by_name(n)
self.assertEqual(c.address_type, a)
self.assertEqual(c.coin_shortcut, s)
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
def test_altcoins(self):
ref = [
('NMC', 'Namecoin', 52), ('NMC', 'Namecoin', 52),
('LTC', 'Litecoin', 48), ('LTC', 'Litecoin', 48),
('DASH', 'Dash', 76), ('DASH', 'Dash', 76),

View File

@ -1,22 +1,24 @@
from common import * from common import *
from apps.eos.actions import check_action if not utils.BITCOIN_ONLY:
from trezor.messages.EosTxActionAck import EosTxActionAck from apps.eos.actions import check_action
from trezor.messages.EosActionBuyRam import EosActionBuyRam from trezor.messages.EosTxActionAck import EosTxActionAck
from trezor.messages.EosActionBuyRamBytes import EosActionBuyRamBytes from trezor.messages.EosActionBuyRam import EosActionBuyRam
from trezor.messages.EosActionDelegate import EosActionDelegate from trezor.messages.EosActionBuyRamBytes import EosActionBuyRamBytes
from trezor.messages.EosActionDeleteAuth import EosActionDeleteAuth from trezor.messages.EosActionDelegate import EosActionDelegate
from trezor.messages.EosActionLinkAuth import EosActionLinkAuth from trezor.messages.EosActionDeleteAuth import EosActionDeleteAuth
from trezor.messages.EosActionNewAccount import EosActionNewAccount from trezor.messages.EosActionLinkAuth import EosActionLinkAuth
from trezor.messages.EosActionRefund import EosActionRefund from trezor.messages.EosActionNewAccount import EosActionNewAccount
from trezor.messages.EosActionSellRam import EosActionSellRam from trezor.messages.EosActionRefund import EosActionRefund
from trezor.messages.EosActionTransfer import EosActionTransfer from trezor.messages.EosActionSellRam import EosActionSellRam
from trezor.messages.EosActionUndelegate import EosActionUndelegate from trezor.messages.EosActionTransfer import EosActionTransfer
from trezor.messages.EosActionUnlinkAuth import EosActionUnlinkAuth from trezor.messages.EosActionUndelegate import EosActionUndelegate
from trezor.messages.EosActionUpdateAuth import EosActionUpdateAuth from trezor.messages.EosActionUnlinkAuth import EosActionUnlinkAuth
from trezor.messages.EosActionVoteProducer import EosActionVoteProducer from trezor.messages.EosActionUpdateAuth import EosActionUpdateAuth
from trezor.messages.EosActionVoteProducer import EosActionVoteProducer
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestEosActions(unittest.TestCase): class TestEosActions(unittest.TestCase):
def test_check_action(self): def test_check_action(self):
# return True # return True

View File

@ -1,8 +1,11 @@
from common import * from common import *
from apps.eos import helpers if not utils.BITCOIN_ONLY:
from trezor.messages.EosAsset import EosAsset from apps.eos import helpers
from trezor.messages.EosAsset import EosAsset
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestEosConversions(unittest.TestCase): class TestEosConversions(unittest.TestCase):
def test_eos_name_to_string(self): def test_eos_name_to_string(self):
names_in = [ names_in = [

View File

@ -1,12 +1,14 @@
from common import * from common import *
from apps.eos.get_public_key import _get_public_key, _public_key_to_wif
from trezor.crypto import bip32, bip39 from trezor.crypto import bip32, bip39
from ubinascii import hexlify, unhexlify
from apps.common.paths import HARDENED from apps.common.paths import HARDENED
from apps.eos.helpers import validate_full_path
if not utils.BITCOIN_ONLY:
from apps.eos.get_public_key import _get_public_key, _public_key_to_wif
from apps.eos.helpers import validate_full_path
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestEosGetPublicKey(unittest.TestCase): class TestEosGetPublicKey(unittest.TestCase):
def test_get_public_key_scheme(self): def test_get_public_key_scheme(self):
mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"

View File

@ -1,9 +1,12 @@
from common import * from common import *
from apps.common.paths import HARDENED from apps.common.paths import HARDENED
from apps.ethereum.address import address_from_bytes, bytes_from_address, validate_full_path
from apps.ethereum.networks import NetworkInfo, by_chain_id if not utils.BITCOIN_ONLY:
from apps.ethereum.address import address_from_bytes, bytes_from_address, validate_full_path
from apps.ethereum.networks import NetworkInfo, by_chain_id
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestEthereumGetAddress(unittest.TestCase): class TestEthereumGetAddress(unittest.TestCase):
def test_address_from_bytes_eip55(self): def test_address_from_bytes_eip55(self):

View File

@ -1,8 +1,11 @@
from common import * from common import *
from apps.ethereum.layout import format_ethereum_amount
from apps.ethereum.tokens import token_by_chain_address if not utils.BITCOIN_ONLY:
from apps.ethereum.layout import format_ethereum_amount
from apps.ethereum.tokens import token_by_chain_address
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestEthereumLayout(unittest.TestCase): class TestEthereumLayout(unittest.TestCase):
def test_format(self): def test_format(self):

View File

@ -1,7 +1,10 @@
from common import * from common import *
from apps.ethereum import tokens
if not utils.BITCOIN_ONLY:
from apps.ethereum import tokens
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestEthereumTokens(unittest.TestCase): class TestEthereumTokens(unittest.TestCase):
def test_token_by_chain_address(self): def test_token_by_chain_address(self):

View File

@ -1,8 +1,11 @@
from common import * from common import *
from apps.common.paths import HARDENED from apps.common.paths import HARDENED
from apps.lisk.helpers import validate_full_path
if not utils.BITCOIN_ONLY:
from apps.lisk.helpers import validate_full_path
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestLiskGetAddress(unittest.TestCase): class TestLiskGetAddress(unittest.TestCase):
def test_paths(self): def test_paths(self):

View File

@ -1,8 +1,11 @@
from common import * from common import *
from apps.common.paths import HARDENED from apps.common.paths import HARDENED
from apps.monero.misc import validate_full_path
if not utils.BITCOIN_ONLY:
from apps.monero.misc import validate_full_path
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestMoneroGetAddress(unittest.TestCase): class TestMoneroGetAddress(unittest.TestCase):
def test_paths(self): def test_paths(self):

View File

@ -1,10 +1,13 @@
from common import * from common import *
from apps.monero.xmr import bulletproof as bp, crypto, monero if not utils.BITCOIN_ONLY:
from apps.monero.xmr.serialize_messages.tx_rsig_bulletproof import Bulletproof from apps.monero.xmr import bulletproof as bp, crypto, monero
from apps.monero.xmr.serialize_messages.tx_rsig_bulletproof import Bulletproof
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestMoneroBulletproof(unittest.TestCase): class TestMoneroBulletproof(unittest.TestCase):
def test_1(self): def test_1(self):
pass pass

View File

@ -1,12 +1,15 @@
from common import * from common import *
from apps.monero.xmr import crypto, monero if not utils.BITCOIN_ONLY:
from apps.monero.xmr.addresses import encode_addr from apps.monero.xmr import crypto, monero
from apps.monero.xmr.credentials import AccountCreds from apps.monero.xmr.addresses import encode_addr
from apps.monero.xmr.networks import NetworkTypes, net_version from apps.monero.xmr.credentials import AccountCreds
from apps.monero.xmr.networks import NetworkTypes, net_version
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestMoneroCrypto(unittest.TestCase): class TestMoneroCrypto(unittest.TestCase):
def test_encoding(self): def test_encoding(self):
point = unhexlify( point = unhexlify(
b"2486224797d05cae3cba4be043be2db0df381f3f19cfa113f86ab38e3d8d2bd0" b"2486224797d05cae3cba4be043be2db0df381f3f19cfa113f86ab38e3d8d2bd0"

View File

@ -2,72 +2,75 @@ import utest
from common import * from common import *
from trezor import log, loop, utils from trezor import log, loop, utils
from apps.monero.xmr.serialize.int_serialize import ( if not utils.BITCOIN_ONLY:
dump_uint, from apps.monero.xmr.serialize.int_serialize import (
dump_uvarint, dump_uint,
load_uint, dump_uvarint,
load_uvarint, load_uint,
) load_uvarint,
from apps.monero.xmr.serialize.readwriter import MemoryReaderWriter )
from apps.monero.xmr.serialize_messages.base import ECPoint from apps.monero.xmr.serialize.readwriter import MemoryReaderWriter
from apps.monero.xmr.serialize_messages.tx_prefix import ( from apps.monero.xmr.serialize_messages.base import ECPoint
TxinGen, from apps.monero.xmr.serialize_messages.tx_prefix import (
TxinToKey, TxinGen,
TxInV, TxinToKey,
TxOut, TxInV,
TxoutToKey, TxOut,
) TxoutToKey,
)
class XmrTstData(object): if not utils.BITCOIN_ONLY:
"""Simple tests data generator""" class XmrTstData(object):
"""Simple tests data generator"""
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(XmrTstData, self).__init__() super(XmrTstData, self).__init__()
self.ec_offset = 0 self.ec_offset = 0
def reset(self): def reset(self):
self.ec_offset = 0 self.ec_offset = 0
def generate_ec_key(self, use_offset=True): def generate_ec_key(self, use_offset=True):
""" """
Returns test EC key, 32 element byte array Returns test EC key, 32 element byte array
:param use_offset: :param use_offset:
:return: :return:
""" """
offset = 0 offset = 0
if use_offset: if use_offset:
offset = self.ec_offset offset = self.ec_offset
self.ec_offset += 1 self.ec_offset += 1
return bytearray(range(offset, offset + 32)) return bytearray(range(offset, offset + 32))
def gen_transaction_prefix(self): def gen_transaction_prefix(self):
""" """
Returns test transaction prefix Returns test transaction prefix
:return: :return:
""" """
vin = [ vin = [
TxinToKey( TxinToKey(
amount=123, key_offsets=[1, 2, 3, 2 ** 76], k_image=bytearray(range(32)) amount=123, key_offsets=[1, 2, 3, 2 ** 76], k_image=bytearray(range(32))
), ),
TxinToKey( TxinToKey(
amount=456, key_offsets=[9, 8, 7, 6], k_image=bytearray(range(32, 64)) amount=456, key_offsets=[9, 8, 7, 6], k_image=bytearray(range(32, 64))
), ),
TxinGen(height=99), TxinGen(height=99),
] ]
vout = [ vout = [
TxOut(amount=11, target=TxoutToKey(key=bytearray(range(32)))), TxOut(amount=11, target=TxoutToKey(key=bytearray(range(32)))),
TxOut(amount=34, target=TxoutToKey(key=bytearray(range(64, 96)))), TxOut(amount=34, target=TxoutToKey(key=bytearray(range(64, 96)))),
] ]
msg = TransactionPrefix( msg = TransactionPrefix(
version=2, unlock_time=10, vin=vin, vout=vout, extra=list(range(31)) version=2, unlock_time=10, vin=vin, vout=vout, extra=list(range(31))
) )
return msg return msg
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestMoneroSerializer(unittest.TestCase): class TestMoneroSerializer(unittest.TestCase):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(TestMoneroSerializer, self).__init__(*args, **kwargs) super(TestMoneroSerializer, self).__init__(*args, **kwargs)

View File

@ -1,10 +1,12 @@
from common import * from common import *
from ubinascii import unhexlify
from trezor.crypto import nem
from apps.common import HARDENED from apps.common import HARDENED
from apps.nem.helpers import check_path, NEM_NETWORK_MAINNET, NEM_NETWORK_TESTNET
if not utils.BITCOIN_ONLY:
from trezor.crypto import nem
from apps.nem.helpers import check_path, NEM_NETWORK_MAINNET, NEM_NETWORK_TESTNET
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestNemAddress(unittest.TestCase): class TestNemAddress(unittest.TestCase):
def test_addresses(self): def test_addresses(self):

View File

@ -1,10 +1,12 @@
from common import * from common import *
from ubinascii import unhexlify
from trezor.crypto import bip32 from trezor.crypto import bip32
from apps.nem import CURVE
from apps.nem.helpers import NEM_NETWORK_MAINNET if not utils.BITCOIN_ONLY:
from apps.nem import CURVE
from apps.nem.helpers import NEM_NETWORK_MAINNET
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestNemHDNode(unittest.TestCase): class TestNemHDNode(unittest.TestCase):
def test_addresses(self): def test_addresses(self):

View File

@ -1,10 +1,13 @@
from common import * from common import *
from trezor.messages.NEMMosaic import NEMMosaic
from apps.nem.mosaic.helpers import get_mosaic_definition if not utils.BITCOIN_ONLY:
from apps.nem.transfer import * from trezor.messages.NEMMosaic import NEMMosaic
from apps.nem.transfer.serialize import * from apps.nem.mosaic.helpers import get_mosaic_definition
from apps.nem.transfer import *
from apps.nem.transfer.serialize import *
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestNemMosaic(unittest.TestCase): class TestNemMosaic(unittest.TestCase):
def test_get_mosaic_definition(self): def test_get_mosaic_definition(self):

View File

@ -1,15 +1,17 @@
from common import * from common import *
from apps.nem.helpers import *
from apps.nem.mosaic import *
from apps.nem.mosaic.serialize import *
from trezor.crypto import hashlib from trezor.crypto import hashlib
from trezor.messages.NEMSignTx import NEMSignTx
from trezor.messages.NEMMosaicCreation import NEMMosaicCreation if not utils.BITCOIN_ONLY:
from trezor.messages.NEMMosaicDefinition import NEMMosaicDefinition from trezor.messages.NEMSignTx import NEMSignTx
from trezor.messages.NEMMosaicCreation import NEMMosaicCreation
from trezor.messages.NEMMosaicDefinition import NEMMosaicDefinition
from apps.nem.helpers import *
from apps.nem.mosaic import *
from apps.nem.mosaic.serialize import *
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestNemMosaicCreation(unittest.TestCase): class TestNemMosaicCreation(unittest.TestCase):
def test_nem_transaction_mosaic_creation(self): def test_nem_transaction_mosaic_creation(self):

View File

@ -1,14 +1,16 @@
from common import * from common import *
from apps.nem.helpers import *
from apps.nem.mosaic import *
from apps.nem.mosaic.serialize import *
from trezor.crypto import hashlib from trezor.crypto import hashlib
from trezor.messages.NEMSignTx import NEMSignTx
from trezor.messages.NEMMosaicSupplyChange import NEMMosaicSupplyChange if not utils.BITCOIN_ONLY:
from apps.nem.helpers import *
from apps.nem.mosaic import *
from apps.nem.mosaic.serialize import *
from trezor.messages.NEMSignTx import NEMSignTx
from trezor.messages.NEMMosaicSupplyChange import NEMMosaicSupplyChange
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestNemMosaicSupplyChange(unittest.TestCase): class TestNemMosaicSupplyChange(unittest.TestCase):
def test_nem_transaction_create_mosaic_supply_change(self): def test_nem_transaction_create_mosaic_supply_change(self):

View File

@ -1,15 +1,17 @@
from common import * from common import *
from trezor.crypto import hashlib from trezor.crypto import hashlib
from trezor.messages.NEMAggregateModification import NEMAggregateModification
from trezor.messages.NEMCosignatoryModification import NEMCosignatoryModification
from trezor.messages.NEMSignTx import NEMSignTx
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from apps.nem.helpers import * if not utils.BITCOIN_ONLY:
from apps.nem.multisig import * from trezor.messages.NEMAggregateModification import NEMAggregateModification
from apps.nem.multisig.serialize import * from trezor.messages.NEMCosignatoryModification import NEMCosignatoryModification
from trezor.messages.NEMSignTx import NEMSignTx
from trezor.messages.NEMTransactionCommon import NEMTransactionCommon
from apps.nem.helpers import *
from apps.nem.multisig import *
from apps.nem.multisig.serialize import *
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestNemMultisigAggregateModification(unittest.TestCase): class TestNemMultisigAggregateModification(unittest.TestCase):
def test_nem_transaction_aggregate_modification(self): def test_nem_transaction_aggregate_modification(self):
# http://bob.nem.ninja:8765/#/aggregate/6a55471b17159e5b6cd579c421e95a4e39d92e3f78b0a55ee337e785a601d3a2 # http://bob.nem.ninja:8765/#/aggregate/6a55471b17159e5b6cd579c421e95a4e39d92e3f78b0a55ee337e785a601d3a2

View File

@ -1,17 +1,18 @@
from common import * from common import *
from apps.nem.helpers import * if not utils.BITCOIN_ONLY:
from apps.nem.multisig import * from apps.nem.helpers import *
from apps.nem.multisig.serialize import * from apps.nem.multisig import *
from apps.nem.namespace import * from apps.nem.multisig.serialize import *
from apps.nem.namespace.serialize import * from apps.nem.namespace import *
from apps.nem.namespace.serialize import *
from trezor.messages.NEMSignTx import NEMSignTx from trezor.messages.NEMSignTx import NEMSignTx
from trezor.messages.NEMAggregateModification import NEMAggregateModification from trezor.messages.NEMAggregateModification import NEMAggregateModification
from trezor.messages.NEMProvisionNamespace import NEMProvisionNamespace from trezor.messages.NEMProvisionNamespace import NEMProvisionNamespace
from trezor.messages.NEMCosignatoryModification import NEMCosignatoryModification from trezor.messages.NEMCosignatoryModification import NEMCosignatoryModification
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestNemMultisig(unittest.TestCase): class TestNemMultisig(unittest.TestCase):
def test_nem_multisig(self): def test_nem_multisig(self):

View File

@ -1,14 +1,16 @@
from common import * from common import *
from apps.nem.helpers import *
from apps.nem.namespace import *
from apps.nem.namespace.serialize import *
from trezor.crypto import hashlib from trezor.crypto import hashlib
from trezor.messages.NEMProvisionNamespace import NEMProvisionNamespace
from trezor.messages.NEMSignTx import NEMSignTx if not utils.BITCOIN_ONLY:
from apps.nem.helpers import *
from apps.nem.namespace import *
from apps.nem.namespace.serialize import *
from trezor.messages.NEMProvisionNamespace import NEMProvisionNamespace
from trezor.messages.NEMSignTx import NEMSignTx
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestNemNamespace(unittest.TestCase): class TestNemNamespace(unittest.TestCase):
def test_create_provision_namespace(self): def test_create_provision_namespace(self):

View File

@ -1,15 +1,17 @@
from common import * from common import *
from apps.nem.helpers import *
from apps.nem.mosaic import *
from apps.nem.transfer import *
from apps.nem.transfer.serialize import *
from trezor.crypto import hashlib from trezor.crypto import hashlib
from trezor.messages.NEMTransfer import NEMTransfer
from trezor.messages.NEMSignTx import NEMSignTx if not utils.BITCOIN_ONLY:
from apps.nem.helpers import *
from apps.nem.mosaic import *
from apps.nem.transfer import *
from apps.nem.transfer.serialize import *
from trezor.messages.NEMTransfer import NEMTransfer
from trezor.messages.NEMSignTx import NEMSignTx
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestNemTransfer(unittest.TestCase): class TestNemTransfer(unittest.TestCase):
def test_create_transfer(self): def test_create_transfer(self):

View File

@ -1,8 +1,11 @@
from common import * from common import *
from apps.common.paths import HARDENED from apps.common.paths import HARDENED
from apps.ripple.helpers import address_from_public_key, validate_full_path
if not utils.BITCOIN_ONLY:
from apps.ripple.helpers import address_from_public_key, validate_full_path
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestRippleAddress(unittest.TestCase): class TestRippleAddress(unittest.TestCase):
def test_pubkey_to_address(self): def test_pubkey_to_address(self):

View File

@ -1,11 +1,13 @@
from common import * from common import *
from trezor.messages.RipplePayment import RipplePayment
from trezor.messages.RippleSignTx import RippleSignTx
from apps.ripple.serialize import serialize, serialize_amount if not utils.BITCOIN_ONLY:
from apps.ripple.sign_tx import get_network_prefix from trezor.messages.RipplePayment import RipplePayment
from trezor.messages.RippleSignTx import RippleSignTx
from apps.ripple.serialize import serialize, serialize_amount
from apps.ripple.sign_tx import get_network_prefix
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestRippleSerializer(unittest.TestCase): class TestRippleSerializer(unittest.TestCase):
def test_amount(self): def test_amount(self):
# https://github.com/ripple/ripple-binary-codec/blob/4581f1b41e712f545ba08be15e188a557c731ecf/test/fixtures/data-driven-tests.json#L2494 # https://github.com/ripple/ripple-binary-codec/blob/4581f1b41e712f545ba08be15e188a557c731ecf/test/fixtures/data-driven-tests.json#L2494

View File

@ -1,9 +1,12 @@
from common import * from common import *
from apps.common.paths import HARDENED from apps.common.paths import HARDENED
from apps.stellar.helpers import address_from_public_key, public_key_from_address, validate_full_path
from trezor.wire import ProcessError from trezor.wire import ProcessError
if not utils.BITCOIN_ONLY:
from apps.stellar.helpers import address_from_public_key, public_key_from_address, validate_full_path
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestStellarAddress(unittest.TestCase): class TestStellarAddress(unittest.TestCase):
def test_address_to_pubkey(self): def test_address_to_pubkey(self):

View File

@ -1,14 +1,15 @@
from ubinascii import unhexlify
from common import * from common import *
from trezor.messages import TezosContractType
from trezor.messages.TezosContractID import TezosContractID
from apps.tezos.sign_tx import _get_address_from_contract
from apps.tezos.helpers import validate_full_path
from apps.common.paths import HARDENED from apps.common.paths import HARDENED
if not utils.BITCOIN_ONLY:
from apps.tezos.sign_tx import _get_address_from_contract
from apps.tezos.helpers import validate_full_path
from trezor.messages import TezosContractType
from trezor.messages.TezosContractID import TezosContractID
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestTezosAddress(unittest.TestCase): class TestTezosAddress(unittest.TestCase):
def test_get_address_from_contract(self): def test_get_address_from_contract(self):
contracts = [ contracts = [

View File

@ -1,17 +1,17 @@
from ubinascii import unhexlify
from common import * from common import *
from trezor.messages import TezosContractType
from trezor.messages.TezosContractID import TezosContractID
from apps.tezos.helpers import base58_decode_check, base58_encode_check, write_bool if not utils.BITCOIN_ONLY:
from apps.tezos.sign_tx import ( from trezor.messages import TezosContractType
_encode_contract_id, from trezor.messages.TezosContractID import TezosContractID
_encode_data_with_bool_prefix, from apps.tezos.helpers import base58_decode_check, base58_encode_check, write_bool
_encode_zarith, from apps.tezos.sign_tx import (
) _encode_contract_id,
_encode_data_with_bool_prefix,
_encode_zarith,
)
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestTezosEncoding(unittest.TestCase): class TestTezosEncoding(unittest.TestCase):
def test_tezos_encode_zarith(self): def test_tezos_encode_zarith(self):
inputs = [2000000, 159066, 200, 60000, 157000000, 0] inputs = [2000000, 159066, 200, 60000, 157000000, 0]

View File

@ -169,6 +169,7 @@ class TestAddress(unittest.TestCase):
self.assertFalse(validate_full_path([44 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0, 0], coin, InputScriptType.SPENDWITNESS)) self.assertFalse(validate_full_path([44 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0, 0], coin, InputScriptType.SPENDWITNESS))
self.assertTrue(validate_full_path([44 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0, 0], coin, InputScriptType.SPENDWITNESS, validate_script_type=False)) self.assertTrue(validate_full_path([44 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0, 0], coin, InputScriptType.SPENDWITNESS, validate_script_type=False))
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
def test_paths_bch(self): def test_paths_bch(self):
incorrect_derivation_paths = [ incorrect_derivation_paths = [
([44 | HARDENED], InputScriptType.SPENDADDRESS), # invalid length ([44 | HARDENED], InputScriptType.SPENDADDRESS), # invalid length
@ -201,6 +202,7 @@ class TestAddress(unittest.TestCase):
for path, input_type in correct_derivation_paths: for path, input_type in correct_derivation_paths:
self.assertTrue(validate_full_path(path, coin, input_type)) self.assertTrue(validate_full_path(path, coin, input_type))
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
def test_paths_other(self): def test_paths_other(self):
incorrect_derivation_paths = [ incorrect_derivation_paths = [
([44 | HARDENED, 3 | HARDENED, 0 | HARDENED, 0, 0], InputScriptType.SPENDMULTISIG), # input type mismatch ([44 | HARDENED, 3 | HARDENED, 0 | HARDENED, 0, 0], InputScriptType.SPENDMULTISIG), # input type mismatch
@ -244,6 +246,8 @@ class TestAddress(unittest.TestCase):
for path in incorrect_derivation_paths: for path in incorrect_derivation_paths:
self.assertFalse(validate_path_for_bitcoin_public_key(path, coin)) self.assertFalse(validate_path_for_bitcoin_public_key(path, coin))
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
def test_paths_public_key_nosegwit(self):
incorrect_derivation_paths = [ incorrect_derivation_paths = [
[49 | HARDENED, 3 | HARDENED, 0 | HARDENED, 0, 0], # no segwit [49 | HARDENED, 3 | HARDENED, 0 | HARDENED, 0, 0], # no segwit
] ]

View File

@ -12,6 +12,7 @@ def node_derive(root, path):
return node return node
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestAddressGRS(unittest.TestCase): class TestAddressGRS(unittest.TestCase):
# pylint: disable=C0301 # pylint: disable=C0301

View File

@ -19,6 +19,7 @@ from apps.common.seed import Keychain
from apps.wallet.sign_tx import helpers, signing from apps.wallet.sign_tx import helpers, signing
# https://groestlsight-test.groestlcoin.org/api/tx/9b5c4859a8a31e69788cb4402812bb28f14ad71cbd8c60b09903478bc56f79a3 # https://groestlsight-test.groestlcoin.org/api/tx/9b5c4859a8a31e69788cb4402812bb28f14ad71cbd8c60b09903478bc56f79a3
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase): class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase):
# pylint: disable=C0301 # pylint: disable=C0301

View File

@ -19,6 +19,7 @@ from apps.common.seed import Keychain
from apps.wallet.sign_tx import helpers, signing from apps.wallet.sign_tx import helpers, signing
# https://groestlsight-test.groestlcoin.org/api/tx/4ce0220004bdfe14e3dd49fd8636bcb770a400c0c9e9bff670b6a13bb8f15c72 # https://groestlsight-test.groestlcoin.org/api/tx/4ce0220004bdfe14e3dd49fd8636bcb770a400c0c9e9bff670b6a13bb8f15c72
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase): class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase):
# pylint: disable=C0301 # pylint: disable=C0301

View File

@ -19,6 +19,7 @@ from apps.common.seed import Keychain
from apps.wallet.sign_tx import helpers, signing from apps.wallet.sign_tx import helpers, signing
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestSignTx_GRS(unittest.TestCase): class TestSignTx_GRS(unittest.TestCase):
# pylint: disable=C0301 # pylint: disable=C0301

View File

@ -5,10 +5,13 @@ from trezor.messages.TxInputType import TxInputType
from trezor.messages.TxOutputBinType import TxOutputBinType from trezor.messages.TxOutputBinType import TxOutputBinType
from apps.common import coins from apps.common import coins
from apps.wallet.sign_tx.zcash import Zip143
if not utils.BITCOIN_ONLY:
from apps.wallet.sign_tx.zcash import Zip143
# test vectors inspired from https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/zip_0143.py # test vectors inspired from https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/zip_0143.py
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestZcashZip143(unittest.TestCase): class TestZcashZip143(unittest.TestCase):
VECTORS = [ VECTORS = [

View File

@ -5,10 +5,13 @@ from trezor.messages.TxInputType import TxInputType
from trezor.messages.TxOutputBinType import TxOutputBinType from trezor.messages.TxOutputBinType import TxOutputBinType
from apps.common import coins from apps.common import coins
from apps.wallet.sign_tx.zcash import Zip243
if not utils.BITCOIN_ONLY:
from apps.wallet.sign_tx.zcash import Zip243
# test vectors inspired from https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/zip_0243.py # test vectors inspired from https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/zip_0243.py
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestZcashZip243(unittest.TestCase): class TestZcashZip243(unittest.TestCase):
VECTORS = [ VECTORS = [

View File

@ -1,7 +1,11 @@
from common import * from common import *
from trezor.crypto import random from trezor.crypto import random
from trezor.crypto.curve import secp256k1, secp256k1_zkp from trezor.crypto.curve import secp256k1
if not utils.BITCOIN_ONLY:
from trezor.crypto.curve import secp256k1_zkp
class Secp256k1Common(object): class Secp256k1Common(object):
impl = None impl = None
@ -137,6 +141,7 @@ class TestCryptoSecp256k1(Secp256k1Common, unittest.TestCase):
def __init__(self): def __init__(self):
self.impl = secp256k1 self.impl = secp256k1
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
class TestCryptoSecp256k1Zkp(Secp256k1Common, unittest.TestCase): class TestCryptoSecp256k1Zkp(Secp256k1Common, unittest.TestCase):
def __init__(self): def __init__(self):
self.impl = secp256k1_zkp.Context() self.impl = secp256k1_zkp.Context()