2018-06-21 14:28:34 +00:00
|
|
|
# This file is part of the Trezor project.
|
|
|
|
#
|
2019-05-29 16:44:09 +00:00
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
2018-06-11 13:03:20 +00:00
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
2018-06-21 14:28:34 +00:00
|
|
|
# it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
# as published by the Free Software Foundation.
|
2018-06-11 13:03:20 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2018-06-21 14:28:34 +00:00
|
|
|
# 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>.
|
|
|
|
|
2018-06-11 13:03:20 +00:00
|
|
|
import pytest
|
|
|
|
|
2019-08-27 14:58:59 +00:00
|
|
|
from trezorlib import messages as proto, stellar
|
2020-03-24 13:18:08 +00:00
|
|
|
from trezorlib.exceptions import TrezorFailure
|
|
|
|
from trezorlib.tools import parse_path
|
2018-08-13 16:21:24 +00:00
|
|
|
|
2019-09-11 12:43:32 +00:00
|
|
|
from ..common import MNEMONIC12
|
2018-06-11 13:03:20 +00:00
|
|
|
|
|
|
|
|
2019-08-22 16:47:01 +00:00
|
|
|
@pytest.mark.altcoin
|
2018-06-11 13:03:20 +00:00
|
|
|
@pytest.mark.stellar
|
2019-09-11 12:29:39 +00:00
|
|
|
class TestMsgStellarGetAddress:
|
2019-08-27 14:58:59 +00:00
|
|
|
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
|
|
|
|
def test_stellar_get_address(self, client):
|
|
|
|
address = stellar.get_address(client, parse_path(stellar.DEFAULT_BIP32_PATH))
|
2018-08-13 16:21:24 +00:00
|
|
|
assert address == "GAK5MSF74TJW6GLM7NLTL76YZJKM2S4CGP3UH4REJHPHZ4YBZW2GSBPW"
|
2018-06-11 13:03:20 +00:00
|
|
|
|
2019-08-27 14:58:59 +00:00
|
|
|
@pytest.mark.setup_client(
|
|
|
|
mnemonic="illness spike retreat truth genius clock brain pass fit cave bargain toe"
|
|
|
|
)
|
|
|
|
def test_stellar_get_address_sep(self, client):
|
2018-06-26 09:52:47 +00:00
|
|
|
# data from https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md
|
2019-08-27 14:58:59 +00:00
|
|
|
address = stellar.get_address(client, parse_path(stellar.DEFAULT_BIP32_PATH))
|
2018-08-13 16:21:24 +00:00
|
|
|
assert address == "GDRXE2BQUC3AZNPVFSCEZ76NJ3WWL25FYFK6RGZGIEKWE4SOOHSUJUJ6"
|
2018-06-26 09:52:47 +00:00
|
|
|
|
2018-08-13 16:21:24 +00:00
|
|
|
address = stellar.get_address(
|
2019-08-27 14:58:59 +00:00
|
|
|
client, parse_path("m/44h/148h/1h"), show_display=True
|
2018-08-13 16:21:24 +00:00
|
|
|
)
|
|
|
|
assert address == "GBAW5XGWORWVFE2XTJYDTLDHXTY2Q2MO73HYCGB3XMFMQ562Q2W2GJQX"
|
2018-06-26 09:52:47 +00:00
|
|
|
|
2019-08-27 14:58:59 +00:00
|
|
|
def test_stellar_get_address_fail(self, client):
|
2020-03-24 13:18:08 +00:00
|
|
|
with pytest.raises(TrezorFailure) as exc:
|
2019-08-27 14:58:59 +00:00
|
|
|
stellar.get_address(client, parse_path("m/0/1"))
|
2018-06-11 17:22:16 +00:00
|
|
|
|
2019-09-11 12:36:26 +00:00
|
|
|
if client.features.model == "1":
|
2020-03-24 15:24:53 +00:00
|
|
|
assert exc.value.code == proto.FailureType.ProcessError
|
|
|
|
assert exc.value.message.endswith("Failed to derive private key")
|
2018-06-13 11:40:58 +00:00
|
|
|
else:
|
2020-03-24 15:24:53 +00:00
|
|
|
assert exc.value.code == proto.FailureType.DataError
|
2020-07-24 09:25:26 +00:00
|
|
|
assert exc.value.message == "Non-hardened paths unsupported on Ed25519"
|