1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-20 06:28:09 +00:00
trezor-firmware/tests/device_tests/cardano/test_derivations.py

55 lines
2.0 KiB
Python
Raw Normal View History

# 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
2024-11-15 16:31:22 +00:00
from trezorlib.debuglink import SessionDebugWrapper as Session
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.models("core"),
]
ADDRESS_N = parse_path("m/1852h/1815h/0h")
2024-11-15 16:31:22 +00:00
def test_bad_session(session: Session):
with pytest.raises(TrezorFailure, match="not enabled"):
2024-11-15 16:31:22 +00:00
get_public_key(session, ADDRESS_N, derivation_type=D.ICARUS)
2024-11-15 16:31:22 +00:00
def test_ledger_available_without_cardano(session: Session):
get_public_key(session, ADDRESS_N, derivation_type=D.LEDGER)
2024-11-15 16:31:22 +00:00
@pytest.mark.cardano # derive_cardano=True
def test_ledger_available_with_cardano(session: Session):
get_public_key(session, 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
2024-11-15 16:31:22 +00:00
def test_derivation_irrelevant_on_slip39(session: Session, derivation_type):
pubkey = get_public_key(session, ADDRESS_N, derivation_type=D.ICARUS)
test_pubkey = get_public_key(session, ADDRESS_N, derivation_type=derivation_type)
assert pubkey == test_pubkey