You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.6 KiB
69 lines
2.6 KiB
6 years ago
|
# This file is part of the Trezor project.
|
||
|
#
|
||
5 years ago
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
||
6 years ago
|
#
|
||
|
# This library is free software: you can redistribute it and/or modify
|
||
6 years ago
|
# it under the terms of the GNU Lesser General Public License version 3
|
||
|
# as published by the Free Software Foundation.
|
||
6 years ago
|
#
|
||
|
# 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.
|
||
|
#
|
||
6 years ago
|
# 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>.
|
||
|
|
||
6 years ago
|
import pytest
|
||
|
|
||
6 years ago
|
from trezorlib import debuglink, messages as proto, stellar
|
||
|
from trezorlib.tools import CallException, parse_path
|
||
|
|
||
6 years ago
|
from .common import TrezorTest
|
||
|
from .conftest import TREZOR_VERSION
|
||
|
|
||
|
|
||
|
@pytest.mark.stellar
|
||
|
class TestMsgStellarGetAddress(TrezorTest):
|
||
|
def test_stellar_get_address(self):
|
||
|
self.setup_mnemonic_nopin_nopassphrase()
|
||
|
|
||
6 years ago
|
address = stellar.get_address(
|
||
|
self.client, parse_path(stellar.DEFAULT_BIP32_PATH)
|
||
|
)
|
||
|
assert address == "GAK5MSF74TJW6GLM7NLTL76YZJKM2S4CGP3UH4REJHPHZ4YBZW2GSBPW"
|
||
6 years ago
|
|
||
6 years ago
|
def test_stellar_get_address_sep(self):
|
||
|
# data from https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0005.md
|
||
6 years ago
|
debuglink.load_device_by_mnemonic(
|
||
|
self.client,
|
||
6 years ago
|
mnemonic="illness spike retreat truth genius clock brain pass fit cave bargain toe",
|
||
|
pin="",
|
||
6 years ago
|
passphrase_protection=False,
|
||
6 years ago
|
label="test",
|
||
|
language="english",
|
||
|
)
|
||
6 years ago
|
|
||
6 years ago
|
address = stellar.get_address(
|
||
|
self.client, parse_path(stellar.DEFAULT_BIP32_PATH)
|
||
|
)
|
||
|
assert address == "GDRXE2BQUC3AZNPVFSCEZ76NJ3WWL25FYFK6RGZGIEKWE4SOOHSUJUJ6"
|
||
6 years ago
|
|
||
6 years ago
|
address = stellar.get_address(
|
||
|
self.client, parse_path("m/44h/148h/1h"), show_display=True
|
||
|
)
|
||
|
assert address == "GBAW5XGWORWVFE2XTJYDTLDHXTY2Q2MO73HYCGB3XMFMQ562Q2W2GJQX"
|
||
6 years ago
|
|
||
6 years ago
|
def test_stellar_get_address_fail(self):
|
||
|
self.setup_mnemonic_nopin_nopassphrase()
|
||
|
|
||
|
with pytest.raises(CallException) as exc:
|
||
6 years ago
|
stellar.get_address(self.client, parse_path("m/0/1"))
|
||
6 years ago
|
|
||
6 years ago
|
if TREZOR_VERSION == 1:
|
||
|
assert exc.value.args[0] == proto.FailureType.ProcessError
|
||
6 years ago
|
assert exc.value.args[1].endswith("Failed to derive private key")
|
||
6 years ago
|
else:
|
||
6 years ago
|
assert exc.value.args[0] == proto.FailureType.DataError
|
||
|
assert exc.value.args[1].endswith("Forbidden key path")
|