2021-10-22 14:05:33 +00:00
|
|
|
# This file is part of the Trezor project.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the License along with this library.
|
|
|
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from trezorlib.cardano import get_public_key
|
2022-01-31 12:25:30 +00:00
|
|
|
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
2021-10-22 14:05:33 +00:00
|
|
|
from trezorlib.exceptions import TrezorFailure
|
|
|
|
from trezorlib.messages import CardanoDerivationType as D
|
|
|
|
from trezorlib.tools import parse_path
|
|
|
|
|
|
|
|
from ...common import MNEMONIC_SLIP39_BASIC_20_3of6
|
|
|
|
|
|
|
|
pytestmark = [
|
|
|
|
pytest.mark.altcoin,
|
|
|
|
pytest.mark.cardano,
|
2024-03-11 15:20:08 +00:00
|
|
|
pytest.mark.skip_t1b1,
|
2021-10-22 14:05:33 +00:00
|
|
|
]
|
|
|
|
|
2022-01-31 12:25:30 +00:00
|
|
|
ADDRESS_N = parse_path("m/1852h/1815h/0h")
|
2021-10-22 14:05:33 +00:00
|
|
|
|
|
|
|
|
2022-01-31 12:25:30 +00:00
|
|
|
def test_bad_session(client: Client):
|
2021-10-22 14:05:33 +00:00
|
|
|
client.init_device(new_session=True)
|
|
|
|
with pytest.raises(TrezorFailure, match="not enabled"):
|
|
|
|
get_public_key(client, ADDRESS_N, derivation_type=D.ICARUS)
|
|
|
|
|
|
|
|
client.init_device(new_session=True, derive_cardano=False)
|
|
|
|
with pytest.raises(TrezorFailure, match="not enabled"):
|
|
|
|
get_public_key(client, ADDRESS_N, derivation_type=D.ICARUS)
|
|
|
|
|
|
|
|
|
2022-01-31 12:25:30 +00:00
|
|
|
def test_ledger_available_always(client: Client):
|
2021-10-22 14:05:33 +00:00
|
|
|
client.init_device(new_session=True, derive_cardano=False)
|
|
|
|
get_public_key(client, ADDRESS_N, derivation_type=D.LEDGER)
|
|
|
|
|
|
|
|
client.init_device(new_session=True, derive_cardano=True)
|
|
|
|
get_public_key(client, ADDRESS_N, derivation_type=D.LEDGER)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.setup_client(mnemonic=MNEMONIC_SLIP39_BASIC_20_3of6)
|
|
|
|
@pytest.mark.parametrize("derivation_type", D) # try ALL derivation types
|
2022-01-31 12:25:30 +00:00
|
|
|
def test_derivation_irrelevant_on_slip39(client: Client, derivation_type):
|
2021-10-22 14:05:33 +00:00
|
|
|
client.init_device(new_session=True, derive_cardano=False)
|
|
|
|
pubkey = get_public_key(client, ADDRESS_N, derivation_type=D.ICARUS)
|
|
|
|
test_pubkey = get_public_key(client, ADDRESS_N, derivation_type=derivation_type)
|
|
|
|
assert pubkey == test_pubkey
|