mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 08:38:07 +00:00
fix(tests): enable derive_cardano for Cardano test cases
This commit is contained in:
parent
9922e7ba48
commit
0e4e56711c
@ -22,6 +22,7 @@ from trezorlib.cardano import (
|
||||
get_public_key,
|
||||
parse_optional_bytes,
|
||||
)
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.messages import CardanoAddressType
|
||||
from trezorlib.tools import parse_path
|
||||
|
||||
@ -45,6 +46,8 @@ pytestmark = [
|
||||
"cardano/get_reward_address.json",
|
||||
)
|
||||
def test_cardano_get_address(client, parameters, result):
|
||||
client.init_device(new_session=True, derive_cardano=True)
|
||||
|
||||
address = get_address(
|
||||
client,
|
||||
address_parameters=create_address_parameters(
|
||||
@ -76,11 +79,24 @@ def test_cardano_get_address(client, parameters, result):
|
||||
|
||||
|
||||
@parametrize_using_common_fixtures(
|
||||
"cardano/get_public_key.json", "cardano/get_public_key.slip39.json"
|
||||
"cardano/get_public_key.json",
|
||||
"cardano/get_public_key.slip39.json",
|
||||
)
|
||||
def test_cardano_get_public_key(client, parameters, result):
|
||||
client.init_device(new_session=True, derive_cardano=True)
|
||||
|
||||
key = get_public_key(client, parse_path(parameters["path"]))
|
||||
|
||||
assert key.node.public_key.hex() == result["public_key"]
|
||||
assert key.node.chain_code.hex() == result["chain_code"]
|
||||
assert key.xpub == result["public_key"] + result["chain_code"]
|
||||
|
||||
|
||||
def test_bad_session(client):
|
||||
client.init_device(new_session=True)
|
||||
with pytest.raises(TrezorFailure, match="not enabled"):
|
||||
get_public_key(client, parse_path("m/1852'/1815'/0'"))
|
||||
|
||||
client.init_device(new_session=True, derive_cardano=False)
|
||||
with pytest.raises(TrezorFailure, match="not enabled"):
|
||||
get_public_key(client, parse_path("m/1852'/1815'/0'"))
|
||||
|
@ -32,6 +32,8 @@ pytestmark = [
|
||||
"cardano/get_native_script_hash.json",
|
||||
)
|
||||
def test_cardano_get_native_script_hash(client, parameters, result):
|
||||
client.init_device(new_session=True, derive_cardano=True)
|
||||
|
||||
native_script_hash = get_native_script_hash(
|
||||
client,
|
||||
native_script=parse_native_script(parameters["native_script"]),
|
||||
|
@ -35,6 +35,8 @@ pytestmark = [
|
||||
"cardano/sign_tx.slip39.json",
|
||||
)
|
||||
def test_cardano_sign_tx(client, parameters, result):
|
||||
client.init_device(new_session=True, derive_cardano=True)
|
||||
|
||||
signing_mode = messages.CardanoTxSigningMode.__members__[parameters["signing_mode"]]
|
||||
inputs = [cardano.parse_input(i) for i in parameters["inputs"]]
|
||||
outputs = [cardano.parse_output(o) for o in parameters["outputs"]]
|
||||
@ -80,6 +82,8 @@ def test_cardano_sign_tx(client, parameters, result):
|
||||
"cardano/sign_tx_stake_pool_registration.failed.json",
|
||||
)
|
||||
def test_cardano_sign_tx_failed(client, parameters, result):
|
||||
client.init_device(new_session=True, derive_cardano=True)
|
||||
|
||||
signing_mode = messages.CardanoTxSigningMode.__members__[parameters["signing_mode"]]
|
||||
inputs = [cardano.parse_input(i) for i in parameters["inputs"]]
|
||||
outputs = [cardano.parse_output(o) for o in parameters["outputs"]]
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"cardano-test_address_public_key.py::test_bad_session": "c09de07fbbf1e047442180e2facb5482d06a1a428891b875b7dd93c9e4704ae1",
|
||||
"cardano-test_address_public_key.py::test_cardano_get_address[parameters0-result0]": "e3be7c64097574e795bad1852f3eb7b9d5c4577ed88a845329bacc7350338d74",
|
||||
"cardano-test_address_public_key.py::test_cardano_get_address[parameters1-result1]": "50b6d3e772e77d6f52c7883f89c3b5f196e43865982c6c5b5171a72546e68164",
|
||||
"cardano-test_address_public_key.py::test_cardano_get_address[parameters10-result10]": "31b0bb5d4ab8cbd5293cbdc8c44f722e5e39c1f633eaa1db2186cb138d88dd5c",
|
||||
|
Loading…
Reference in New Issue
Block a user