1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

feat(tests): add device tests for btc.get_descriptor

This commit is contained in:
Pavol Rusnak 2020-11-21 22:10:02 +01:00
parent 5728f54b78
commit 7b9f3c0462
2 changed files with 149 additions and 0 deletions

View File

@ -0,0 +1,137 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2019 SatoshiLabs and contributors
#
# 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.
#
# 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>.
import pytest
from trezorlib import messages
from trezorlib.cli import btc
VECTORS_DESCRIPTORS = ( # coin, account, script_type, descriptors
(
"Bitcoin",
0,
messages.InputScriptType.SPENDADDRESS,
(
"pkh([5c9e228d/44'/0'/0']xpub6BiVtCpG9fQPxnPmHXG8PhtzQdWC2Su4qWu6XW9tpWFYhxydCLJGrWBJZ5H6qTAHdPQ7pQhtpjiYZVZARo14qHiay2fvrX996oEP42u8wZy/0/*)",
"pkh([5c9e228d/44'/0'/0']xpub6BiVtCpG9fQPxnPmHXG8PhtzQdWC2Su4qWu6XW9tpWFYhxydCLJGrWBJZ5H6qTAHdPQ7pQhtpjiYZVZARo14qHiay2fvrX996oEP42u8wZy/1/*)",
),
),
(
"Bitcoin",
1,
messages.InputScriptType.SPENDADDRESS,
(
"pkh([5c9e228d/44'/0'/1']xpub6BiVtCpG9fQQ1EW99bMSYwySbPWvzTFRQZCFgTmV3samLSZAYU7C3f4Je9vkNh7h1GAWi5Fn93BwoGBy9EAXbWTTgTnVKAbthHpxM1fXVRL/0/*)",
"pkh([5c9e228d/44'/0'/1']xpub6BiVtCpG9fQQ1EW99bMSYwySbPWvzTFRQZCFgTmV3samLSZAYU7C3f4Je9vkNh7h1GAWi5Fn93BwoGBy9EAXbWTTgTnVKAbthHpxM1fXVRL/1/*)",
),
),
(
"Testnet",
0,
messages.InputScriptType.SPENDADDRESS,
(
"pkh([5c9e228d/44'/1'/0']tpubDDKn3FtHc74CaRrRbi1WFdJNaaenZkDWqq9NsEhcafnDZ4VuKeuLG2aKHm5SuwuLgAhRkkfHqcCxpnVNSrs5kJYZXwa6Ud431VnevzzzK3U/0/*)",
"pkh([5c9e228d/44'/1'/0']tpubDDKn3FtHc74CaRrRbi1WFdJNaaenZkDWqq9NsEhcafnDZ4VuKeuLG2aKHm5SuwuLgAhRkkfHqcCxpnVNSrs5kJYZXwa6Ud431VnevzzzK3U/1/*)",
),
),
(
"Testnet",
1,
messages.InputScriptType.SPENDADDRESS,
(
"pkh([5c9e228d/44'/1'/1']tpubDDKn3FtHc74CcBfxJ3zdSNnRacuggmGwv3KEZLJP2LAuqc3HhsQR5ZAVudcQzezzXs7T6QrDtoJJYvgyDUJ9vgWx3Y7Et4Ats1Q25U1LXvU/0/*)",
"pkh([5c9e228d/44'/1'/1']tpubDDKn3FtHc74CcBfxJ3zdSNnRacuggmGwv3KEZLJP2LAuqc3HhsQR5ZAVudcQzezzXs7T6QrDtoJJYvgyDUJ9vgWx3Y7Et4Ats1Q25U1LXvU/1/*)",
),
),
(
"Bitcoin",
0,
messages.InputScriptType.SPENDP2SHWITNESS,
(
"sh(wpkh([5c9e228d/49'/0'/0']xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx/0/*))",
"sh(wpkh([5c9e228d/49'/0'/0']xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx/1/*))",
),
),
(
"Bitcoin",
1,
messages.InputScriptType.SPENDP2SHWITNESS,
(
"sh(wpkh([5c9e228d/49'/0'/1']xpub6CVKsQYXc9ax22ig3KAZMRiJL1xT9Me1sFX3t34mnVVzr6FkciU74qk7AqBkePQ2sM9pKeWp88KfPT2qcVQ19ykqGHMDioJhwywGuJ96Xt8/0/*))",
"sh(wpkh([5c9e228d/49'/0'/1']xpub6CVKsQYXc9ax22ig3KAZMRiJL1xT9Me1sFX3t34mnVVzr6FkciU74qk7AqBkePQ2sM9pKeWp88KfPT2qcVQ19ykqGHMDioJhwywGuJ96Xt8/1/*))",
),
),
(
"Testnet",
0,
messages.InputScriptType.SPENDP2SHWITNESS,
(
"sh(wpkh([5c9e228d/49'/1'/0']tpubDCHRnuvE95JrpEVTUmr36sK3K9ADf3s3aztpXzL8coBeCTE8cHV8PjxS6SjWJM3GfPn798gyEa3dRPgjoUDSuNfuC9xz4PHznwKEk2XL7X1/0/*))",
"sh(wpkh([5c9e228d/49'/1'/0']tpubDCHRnuvE95JrpEVTUmr36sK3K9ADf3s3aztpXzL8coBeCTE8cHV8PjxS6SjWJM3GfPn798gyEa3dRPgjoUDSuNfuC9xz4PHznwKEk2XL7X1/1/*))",
),
),
(
"Testnet",
1,
messages.InputScriptType.SPENDP2SHWITNESS,
(
"sh(wpkh([5c9e228d/49'/1'/1']tpubDCHRnuvE95Jrs9NkLaZwKNdoHBSoCRge6wKunXyxnspvLpx3aZbJcScTnTdsEqT6uFfWdMvBmLs3jhnkBiE7ob3xVQPV8ngDPYAMs93X9xv/0/*))",
"sh(wpkh([5c9e228d/49'/1'/1']tpubDCHRnuvE95Jrs9NkLaZwKNdoHBSoCRge6wKunXyxnspvLpx3aZbJcScTnTdsEqT6uFfWdMvBmLs3jhnkBiE7ob3xVQPV8ngDPYAMs93X9xv/1/*))",
),
),
(
"Bitcoin",
0,
messages.InputScriptType.SPENDWITNESS,
(
"wpkh([5c9e228d/84'/0'/0']xpub6DDUPHpUo4pcy43iJeZjbSVWGav1SMMmuWdMHiGtkK8rhKmfbomtkwW6GKs1GGAKehT6QRocrmda3WWxXawpjmwaUHfFRXuKrXSapdckEYF/0/*)",
"wpkh([5c9e228d/84'/0'/0']xpub6DDUPHpUo4pcy43iJeZjbSVWGav1SMMmuWdMHiGtkK8rhKmfbomtkwW6GKs1GGAKehT6QRocrmda3WWxXawpjmwaUHfFRXuKrXSapdckEYF/1/*)",
),
),
(
"Bitcoin",
1,
messages.InputScriptType.SPENDWITNESS,
(
"wpkh([5c9e228d/84'/0'/1']xpub6DDUPHpUo4pd1hyVtRaknvZvCgdPdEDMKx3bB5UFcx73pEHRDVK4rwEZUgeUbVuYWGMNLvuBHp5WeyPevN2Gv7m9FnLHQE6XaKNRPZcYcHH/0/*)",
"wpkh([5c9e228d/84'/0'/1']xpub6DDUPHpUo4pd1hyVtRaknvZvCgdPdEDMKx3bB5UFcx73pEHRDVK4rwEZUgeUbVuYWGMNLvuBHp5WeyPevN2Gv7m9FnLHQE6XaKNRPZcYcHH/1/*)",
),
),
(
"Testnet",
0,
messages.InputScriptType.SPENDWITNESS,
(
"wpkh([5c9e228d/84'/1'/0']tpubDCZB6sR48s4T5Cr8qHUYSZEFCQMMHRg8AoVKVmvcAP5bRw7ArDKeoNwKAJujV3xCPkBvXH5ejSgbgyN6kREmF7sMd41NdbuHa8n1DZNxSMg/0/*)",
"wpkh([5c9e228d/84'/1'/0']tpubDCZB6sR48s4T5Cr8qHUYSZEFCQMMHRg8AoVKVmvcAP5bRw7ArDKeoNwKAJujV3xCPkBvXH5ejSgbgyN6kREmF7sMd41NdbuHa8n1DZNxSMg/1/*)",
),
),
(
"Testnet",
1,
messages.InputScriptType.SPENDWITNESS,
(
"wpkh([5c9e228d/84'/1'/1']tpubDCZB6sR48s4T6xoXqaYxScvf23kmQvg5QpyFkYnDBjsmviKHLSG9s6cp593Exg87tuMjXXMWDvBRXnJtzppcQf8Z8HdJP1rothfxm4qnPXo/0/*)",
"wpkh([5c9e228d/84'/1'/1']tpubDCZB6sR48s4T6xoXqaYxScvf23kmQvg5QpyFkYnDBjsmviKHLSG9s6cp593Exg87tuMjXXMWDvBRXnJtzppcQf8Z8HdJP1rothfxm4qnPXo/1/*)",
),
),
)
@pytest.mark.parametrize("coin, account, script_type, descriptors", VECTORS_DESCRIPTORS)
def test_descriptors(client, coin, account, script_type, descriptors):
res = btc._get_descriptor(client, coin, account, script_type, show_display=True)
assert res == descriptors

View File

@ -63,6 +63,18 @@
"test_basic.py-test_device_id_same": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_basic.py-test_features": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_basic.py-test_ping": "5a80508a71a9ef64f94762b07636f90e464832f0f4a3102af8fa1a8c69e94586",
"test_descriptors.py::test_descriptors[Bitcoin-0-0-descriptors0]": "148a8d2b84daf91012d819490c414c77b3afc84840e1fec7280ac7ec23b44cd8",
"test_descriptors.py::test_descriptors[Bitcoin-0-3-descriptors8]": "182537adcfefbf22c10266ffcb64c461c7bc6a03353ca88788195be27a4aae80",
"test_descriptors.py::test_descriptors[Bitcoin-0-4-descriptors4]": "0c7f3b16cc9d68a8e3c43daf973eabb3d0953ef075c4818506255f07e3cd2bc1",
"test_descriptors.py::test_descriptors[Bitcoin-1-0-descriptors1]": "f5b652353079a57f7ec81f646540f3bca1ded8476ebc788abc943e9c38604d57",
"test_descriptors.py::test_descriptors[Bitcoin-1-3-descriptors9]": "376a6b35edbc85a7232f9f5d0d9b456b1af45b1816d941db4b44258cfa890b8d",
"test_descriptors.py::test_descriptors[Bitcoin-1-4-descriptors5]": "288e83687815bd8fe14cabf336e2a10383b0eab50a880c61772c491300e28a6d",
"test_descriptors.py::test_descriptors[Testnet-0-0-descriptors2]": "a61fc1d8bbef51423f0196279e7bd6f2f4fd6d0d68fff0589a36d3daa04fb089",
"test_descriptors.py::test_descriptors[Testnet-0-3-descriptors10]": "c5aec5d4ac246de2ab7705e628564469d5bb092843af49ab2f3dc360ba00698e",
"test_descriptors.py::test_descriptors[Testnet-0-4-descriptors6]": "2d5eee0490d2106cf011a6b7201fb473cd0c993a96aa08069a8a301e3f3e768e",
"test_descriptors.py::test_descriptors[Testnet-1-0-descriptors3]": "f5c8563f5c1530b458b67f99fa01bcaf938a684a90e7df36271914f28b9296d8",
"test_descriptors.py::test_descriptors[Testnet-1-3-descriptors11]": "fd013e30635a3b974ad6de96be8ad42394607f9fed0d16e027921569f3680f14",
"test_descriptors.py::test_descriptors[Testnet-1-4-descriptors7]": "0f31ff649f8c5da3a8ff88267c961a92891e232a3aafb9ce6bbf17125e59fa3e",
"test_msg_applysettings.py-test_apply_homescreen_toif": "408bdb69368ebdf1d299c6d43c1571f86cb1a0f1f606c5badd2f05ce7731f121",
"test_msg_applysettings.py-test_apply_settings": "8f9f6013bb8a44fda279e9c7d091328fd7ccb39222a02bee701918528355083a",
"test_msg_applysettings.py-test_apply_settings_passphrase": "40de0143b32b5d06ece43d47be27bb91499f0c2417754ddb8e9e03ff41a7f6d4",