Exemple #1
0
def test_cardano_get_address(client, parameters, result):
    address = get_address(
        client,
        address_parameters=create_address_parameters(
            address_type=getattr(CardanoAddressType,
                                 parameters["address_type"].upper()),
            address_n=parse_path(parameters.get("path"))
            if "path" in parameters else None,
            address_n_staking=parse_path(parameters.get("staking_path"))
            if "staking_path" in parameters else None,
            staking_key_hash=parse_optional_bytes(
                parameters.get("staking_key_hash")),
            block_index=parameters.get("block_index"),
            tx_index=parameters.get("tx_index"),
            certificate_index=parameters.get("certificate_index"),
            script_payment_hash=parse_optional_bytes(
                parameters.get("script_payment_hash")),
            script_staking_hash=parse_optional_bytes(
                parameters.get("script_staking_hash")),
        ),
        protocol_magic=parameters["protocol_magic"],
        network_id=parameters["network_id"],
        show_display=True,
    )
    assert address == result["expected_address"]
def test_cardano_get_address(client, parameters, result):
    client.init_device(new_session=True, derive_cardano=True)

    derivation_type = CardanoDerivationType.__members__[parameters.get(
        "derivation_type", "ICARUS_TREZOR")]

    address = get_address(
        client,
        address_parameters=create_address_parameters(
            address_type=getattr(CardanoAddressType,
                                 parameters["address_type"].upper()),
            address_n=parse_path(parameters.get("path"))
            if "path" in parameters else None,
            address_n_staking=parse_path(parameters.get("staking_path"))
            if "staking_path" in parameters else None,
            staking_key_hash=parse_optional_bytes(
                parameters.get("staking_key_hash")),
            block_index=parameters.get("block_index"),
            tx_index=parameters.get("tx_index"),
            certificate_index=parameters.get("certificate_index"),
            script_payment_hash=parse_optional_bytes(
                parameters.get("script_payment_hash")),
            script_staking_hash=parse_optional_bytes(
                parameters.get("script_staking_hash")),
        ),
        protocol_magic=parameters["protocol_magic"],
        network_id=parameters["network_id"],
        show_display=True,
        derivation_type=derivation_type,
    )
    assert address == result["expected_address"]
Exemple #3
0
def test_cardano_get_address(client, path, protocol_magic, expected_address):
    address = get_address(
        client,
        address_parameters=create_address_parameters(
            address_type=CardanoAddressType.BYRON,
            address_n=tools.parse_path(path),
        ),
        protocol_magic=protocol_magic,
        network_id=NETWORK_IDS["mainnet"],
    )
    assert address == expected_address
Exemple #4
0
def test_cardano_get_reward_address(client, path, network_id,
                                    expected_address):
    address = get_address(
        client,
        address_parameters=create_address_parameters(
            address_type=CardanoAddressType.REWARD,
            address_n=tools.parse_path(path),
        ),
        protocol_magic=PROTOCOL_MAGICS["mainnet"],
        network_id=network_id,
    )
    assert address == expected_address
Exemple #5
0
def test_cardano_get_base_address_with_staking_key_hash(
        client, path, staking_key_hash, network_id, expected_address):
    # data form shelley test vectors
    address = get_address(
        client,
        address_parameters=create_address_parameters(
            address_type=CardanoAddressType.BASE,
            address_n=tools.parse_path(path),
            staking_key_hash=bytes.fromhex(staking_key_hash),
        ),
        protocol_magic=PROTOCOL_MAGICS["mainnet"],
        network_id=network_id,
    )
    assert address == expected_address
Exemple #6
0
def test_cardano_get_address(client, path, protocol_magic, expected_address):
    # enter passphrase
    assert client.features.passphrase_protection is True
    client.use_passphrase("TREZOR")

    address = get_address(
        client,
        address_parameters=create_address_parameters(
            address_type=CardanoAddressType.BYRON, address_n=tools.parse_path(path),
        ),
        protocol_magic=protocol_magic,
        network_id=0,
    )
    assert address == expected_address
    assert address == expected_address
Exemple #7
0
def test_cardano_get_address(client, parameters, result):
    address = get_address(
        client,
        address_parameters=create_address_parameters(
            address_type=getattr(CardanoAddressType,
                                 parameters["address_type"].upper()),
            address_n=parse_path(parameters["path"]),
            address_n_staking=parse_path(parameters.get("staking_path"))
            if "staking_path" in parameters else None,
            staking_key_hash=bytes.fromhex(parameters.get("staking_key_hash"))
            if "staking_key_hash" in parameters else None,
            block_index=parameters.get("block_index"),
            tx_index=parameters.get("tx_index"),
            certificate_index=parameters.get("certificate_index"),
        ),
        protocol_magic=parameters["protocol_magic"],
        network_id=parameters["network_id"],
    )
    assert address == result["expected_address"]
Exemple #8
0
def test_cardano_get_pointer_address(
    client,
    path,
    block_index,
    tx_index,
    certificate_index,
    network_id,
    expected_address,
):
    address = get_address(
        client,
        address_parameters=create_address_parameters(
            address_type=CardanoAddressType.POINTER,
            address_n=tools.parse_path(path),
            block_index=block_index,
            tx_index=tx_index,
            certificate_index=certificate_index,
        ),
        protocol_magic=PROTOCOL_MAGICS["mainnet"],
        network_id=network_id,
    )
    assert address == expected_address