1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-13 19:18:56 +00:00
trezor-firmware/tests/device_tests/test_msg_getaddress_show.py

86 lines
3.0 KiB
Python
Raw Normal View History

# This file is part of the Trezor project.
2017-01-03 18:40:05 +00:00
#
2019-05-29 16:44:09 +00:00
# Copyright (C) 2012-2019 SatoshiLabs and contributors
2017-01-03 18:40:05 +00:00
#
# 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.
2017-01-03 18:40:05 +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.
#
# 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>.
2017-01-03 18:40:05 +00:00
import pytest
from trezorlib import btc, ckd_public as bip32, messages as proto
2018-08-13 16:21:24 +00:00
2019-09-11 12:43:32 +00:00
from ..common import MNEMONIC12
2017-06-23 19:31:42 +00:00
2019-09-11 12:29:39 +00:00
class TestMsgGetaddressShow:
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_show(self, client):
2018-08-13 16:21:24 +00:00
assert (
btc.get_address(client, "Bitcoin", [1], show_display=True)
2018-08-13 16:21:24 +00:00
== "1CK7SJdcb8z9HuvVft3D91HLpLC6KSsGb"
)
assert (
btc.get_address(client, "Bitcoin", [2], show_display=True)
2018-08-13 16:21:24 +00:00
== "15AeAhtNJNKyowK8qPHwgpXkhsokzLtUpG"
)
assert (
btc.get_address(client, "Bitcoin", [3], show_display=True)
2018-08-13 16:21:24 +00:00
== "1CmzyJp9w3NafXMSEFH4SLYUPAVCSUrrJ5"
)
2019-10-22 14:32:00 +00:00
@pytest.mark.multisig
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_show_multisig_3(self, client):
2018-08-13 16:21:24 +00:00
node = bip32.deserialize(
"xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy"
)
multisig = proto.MultisigRedeemScriptType(
2017-06-23 19:31:42 +00:00
pubkeys=[
proto.HDNodePathType(node=node, address_n=[1]),
proto.HDNodePathType(node=node, address_n=[2]),
2018-08-13 16:21:24 +00:00
proto.HDNodePathType(node=node, address_n=[3]),
2017-06-23 19:31:42 +00:00
],
2018-08-13 16:21:24 +00:00
signatures=[b"", b"", b""],
2017-06-23 19:31:42 +00:00
m=2,
)
for i in [1, 2, 3]:
2018-08-13 16:21:24 +00:00
assert (
btc.get_address(
client, "Bitcoin", [i], show_display=True, multisig=multisig
2018-08-13 16:21:24 +00:00
)
== "3E7GDtuHqnqPmDgwH59pVC7AvySiSkbibz"
)
2019-10-22 14:32:00 +00:00
@pytest.mark.multisig
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
def test_show_multisig_15(self, client):
2018-08-13 16:21:24 +00:00
node = bip32.deserialize(
"xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy"
)
2014-12-12 21:31:40 +00:00
pubs = []
for x in range(15):
pubs.append(proto.HDNodePathType(node=node, address_n=[x]))
2014-12-12 21:31:40 +00:00
multisig = proto.MultisigRedeemScriptType(
2018-08-13 16:21:24 +00:00
pubkeys=pubs, signatures=[b""] * 15, m=15
2017-06-23 19:31:42 +00:00
)
for i in range(15):
2018-08-13 16:21:24 +00:00
assert (
btc.get_address(
client, "Bitcoin", [i], show_display=True, multisig=multisig
2018-08-13 16:21:24 +00:00
)
== "3QaKF8zobqcqY8aS6nxCD5ZYdiRfL3RCmU"
)