mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-17 21:22:10 +00:00
feat(test): Add device test for migration to CoinJoin account.
This commit is contained in:
parent
2760322eab
commit
7cbcb25a75
@ -25,7 +25,13 @@ from trezorlib.tools import parse_path
|
||||
|
||||
from ...tx_cache import TxCache
|
||||
from .payment_req import make_coinjoin_request
|
||||
from .signtx import request_finished, request_input, request_output
|
||||
from .signtx import (
|
||||
assert_tx_matches,
|
||||
request_finished,
|
||||
request_input,
|
||||
request_meta,
|
||||
request_output,
|
||||
)
|
||||
|
||||
B = messages.ButtonRequestType
|
||||
|
||||
@ -38,6 +44,12 @@ FAKE_TXHASH_e5b7e2 = bytes.fromhex(
|
||||
FAKE_TXHASH_f982c0 = bytes.fromhex(
|
||||
"f982c0a283bd65a59aa89eded9e48f2a3319cb80361dfab4cf6192a03badb60a"
|
||||
)
|
||||
TXHASH_2cc3c1 = bytes.fromhex(
|
||||
"2cc3c1e33fb1cb7b4fccf4e0fead3fc077a1eb6c22e61561b343b704a5a8da6d"
|
||||
)
|
||||
TXHASH_7f3a34 = bytes.fromhex(
|
||||
"7f3a348106f9f3688069f389c00842b18d26770ec9a96ea94bf21623433a0f72"
|
||||
)
|
||||
|
||||
PIN = "1234"
|
||||
ROUND_ID_LEN = 32
|
||||
@ -472,6 +484,94 @@ def test_sign_tx_spend(client: Client):
|
||||
)
|
||||
|
||||
|
||||
def test_sign_tx_migration(client: Client):
|
||||
inputs = [
|
||||
messages.TxInputType(
|
||||
address_n=parse_path("m/84h/1h/3h/0/12"),
|
||||
amount=1_393,
|
||||
prev_hash=TXHASH_2cc3c1,
|
||||
prev_index=0,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
sequence=0xFFFFFFFD,
|
||||
),
|
||||
messages.TxInputType(
|
||||
address_n=parse_path("m/84h/1h/3h/0/13"),
|
||||
amount=8_159,
|
||||
prev_hash=TXHASH_7f3a34,
|
||||
prev_index=1,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
sequence=0xFFFFFFFD,
|
||||
),
|
||||
]
|
||||
|
||||
outputs = [
|
||||
# CoinJoin account.
|
||||
messages.TxOutputType(
|
||||
# tb1pl3y9gf7xk2ryvmav5ar66ra0d2hk7lhh9mmusx3qvn0n09kmaghqh32ru7
|
||||
address_n=parse_path("m/10025h/1h/0h/1h/0/0"),
|
||||
amount=1_393 + 8_159 - 190,
|
||||
script_type=messages.OutputScriptType.PAYTOTAPROOT,
|
||||
),
|
||||
]
|
||||
|
||||
# Ensure that Trezor refuses to receive to CoinJoin path without the user first authorizing access to CoinJoin paths.
|
||||
with pytest.raises(TrezorFailure, match="Forbidden key path"):
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
client,
|
||||
"Testnet",
|
||||
inputs,
|
||||
outputs,
|
||||
prev_txes=TX_CACHE_TESTNET,
|
||||
)
|
||||
|
||||
with client:
|
||||
tt = client.features.model == "T"
|
||||
client.set_expected_responses(
|
||||
[
|
||||
messages.ButtonRequest(code=B.Other),
|
||||
messages.UnlockedPathRequest(),
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
messages.ButtonRequest(code=B.ConfirmOutput),
|
||||
(tt, messages.ButtonRequest(code=B.ConfirmOutput)),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
(tt, messages.ButtonRequest(code=B.SignTx)),
|
||||
request_input(0),
|
||||
request_meta(TXHASH_2cc3c1),
|
||||
request_input(0, TXHASH_2cc3c1),
|
||||
request_output(0, TXHASH_2cc3c1),
|
||||
request_input(1),
|
||||
request_meta(TXHASH_7f3a34),
|
||||
request_input(0, TXHASH_7f3a34),
|
||||
request_input(1, TXHASH_7f3a34),
|
||||
request_input(2, TXHASH_7f3a34),
|
||||
request_output(0, TXHASH_7f3a34),
|
||||
request_output(1, TXHASH_7f3a34),
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_finished(),
|
||||
]
|
||||
)
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
client,
|
||||
"Testnet",
|
||||
inputs,
|
||||
outputs,
|
||||
prev_txes=TX_CACHE_TESTNET,
|
||||
unlock_path=SLIP25_PATH,
|
||||
)
|
||||
|
||||
assert_tx_matches(
|
||||
serialized_tx,
|
||||
hash_link="https://tbtc1.trezor.io/api/tx/3452d339045f8a35f2a083992b8f73d907f8da9653e89ee175022ca8a649b822",
|
||||
tx_hex="010000000001026ddaa8a504b743b36115e6226ceba177c03fadfee0f4cc4f7bcbb13fe3c1c32c0000000000fdffffff720f3a432316f24ba96ea9c90e77268db14208c089f3698068f3f90681343a7f0100000000fdffffff019224000000000000225120fc485427c6b286466faca747ad0faf6aaf6f7ef72ef7c81a2064df3796dbea2e0247304402202f325d6e3ac764bb9d38003bb11022c5317a59ad8a2513dcabe7af9b23ff7c9f022011ff8161d9ed8cf82667b2b44dbe2f4538d41d8b353d64a01338881bce8de3690121030968050bc0647e28c09616d642cc88ab075b01e40616b53e446e7f122218a9da02483045022100f462c32fd90bf92a1aa4ca9fdb2dd9b5ef9adad6990b9bc7f9ca583e8b72d72a02202a6d9c2a8749d65bdb62a0ec4de27bad5fb13e2ae40be86afb95a477b60a1609012103e4dbaaee8486b328dba46adeb9afc3a56237aa5ca43df24eb61b04e6ca00099300000000",
|
||||
)
|
||||
|
||||
|
||||
def test_wrong_coordinator(client: Client):
|
||||
# Ensure that a preauthorized GetOwnershipProof fails if the commitment_data doesn't match the coordinator.
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"bin_outputs": [
|
||||
{
|
||||
"amount": 1393,
|
||||
"script_pubkey": "001435b1e893609de6ffdf298bc04a0c8067d3849e20"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"coinjoin_flags": 0,
|
||||
"prev_hash": "49b5aaaaa017a75876b0726cc35c2e353b9f38742682c18434a467d76fb9e3d0",
|
||||
"prev_index": 0,
|
||||
"script_sig": "",
|
||||
"script_type": "SPENDADDRESS",
|
||||
"sequence": 4294967293
|
||||
}
|
||||
],
|
||||
"lock_time": 0,
|
||||
"version": 1
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
{
|
||||
"bin_outputs": [
|
||||
{
|
||||
"amount": 601,
|
||||
"script_pubkey": "001481a889eb2bab85282006b6418e3265bff9563a75"
|
||||
},
|
||||
{
|
||||
"amount": 8159,
|
||||
"script_pubkey": "00149076768ac4b06c247dbc1a89b66327a5051bdc0c"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"coinjoin_flags": 0,
|
||||
"prev_hash": "a6d3bc4b297a9dae38a0a4650c191947cefe4bd27ce96699d21df287eb9d457c",
|
||||
"prev_index": 1,
|
||||
"script_sig": "",
|
||||
"script_type": "SPENDADDRESS",
|
||||
"sequence": 4294967293
|
||||
},
|
||||
{
|
||||
"coinjoin_flags": 0,
|
||||
"prev_hash": "bd99f985131e4d008f3fd0cccf54f9bb1cf7752d1fcd04aa485ec69937cd40ae",
|
||||
"prev_index": 0,
|
||||
"script_sig": "",
|
||||
"script_type": "SPENDADDRESS",
|
||||
"sequence": 4294967293
|
||||
},
|
||||
{
|
||||
"coinjoin_flags": 0,
|
||||
"prev_hash": "d5616b728472378f365d2d28215d89c296d28b685e2f15ca7d2e4dccdb73fa5c",
|
||||
"prev_index": 0,
|
||||
"script_sig": "",
|
||||
"script_type": "SPENDADDRESS",
|
||||
"sequence": 4294967293
|
||||
}
|
||||
],
|
||||
"lock_time": 0,
|
||||
"version": 1
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
"T1_bitcoin-test_authorize_coinjoin.py::test_multisession_authorization": "d2ac218c6bc361f732a65daee2ae7183ca935a7b246545ebe6346dbd33d0a702",
|
||||
"T1_bitcoin-test_authorize_coinjoin.py::test_sign_tx": "f630f414daeeb8e0aa3d01ed38a512cb9bfb83abd0c022e01dd02d6824ade61d",
|
||||
"T1_bitcoin-test_authorize_coinjoin.py::test_sign_tx_large": "4365228d89327c72b2d0fa4d487fb28c19ed832e94d8c0c71db83b060c06074a",
|
||||
"T1_bitcoin-test_authorize_coinjoin.py::test_sign_tx_migration": "6aa2d358998e2297b7995c260bf7ee1245c8a10242fe50c9ce96784dc8aa7b79",
|
||||
"T1_bitcoin-test_authorize_coinjoin.py::test_sign_tx_spend": "edeb75022cc6bff15d1274ba9bac4cf41dd8ea5771436010ae07fd441dc73b69",
|
||||
"T1_bitcoin-test_authorize_coinjoin.py::test_wrong_account_type": "60e18060db1756fd0199dd381b41c4b20da89ed1acfe3e1378e2f511d97732bf",
|
||||
"T1_bitcoin-test_authorize_coinjoin.py::test_wrong_coordinator": "60e18060db1756fd0199dd381b41c4b20da89ed1acfe3e1378e2f511d97732bf",
|
||||
@ -681,6 +682,7 @@
|
||||
"TT_bitcoin-test_authorize_coinjoin.py::test_multisession_authorization": "ba3ceb1ebc867d4be866a84714e78581563c0d6d185a20d1e154a4be70e4432c",
|
||||
"TT_bitcoin-test_authorize_coinjoin.py::test_sign_tx": "70223a1375d75eb940c59435c830bb7117c2af439467c26881bea0343ca15c84",
|
||||
"TT_bitcoin-test_authorize_coinjoin.py::test_sign_tx_large": "8954120be7d17be42e0ac881c728fdfe79b7512e1d8744272751215f2502375e",
|
||||
"TT_bitcoin-test_authorize_coinjoin.py::test_sign_tx_migration": "8fa348051144e983e90c118cb26bc2c6a332650b5ff78cea910ed5ee162eb921",
|
||||
"TT_bitcoin-test_authorize_coinjoin.py::test_sign_tx_spend": "cd668beb0174f9142b78fb1573611c46669b066d84f1a09e7d3d0f99687883bf",
|
||||
"TT_bitcoin-test_authorize_coinjoin.py::test_wrong_account_type": "0a37e7e07f7a7ed8cb00b311046e9e91e0fd211e6c2f22b6ebeb69ec22bdda55",
|
||||
"TT_bitcoin-test_authorize_coinjoin.py::test_wrong_coordinator": "0a37e7e07f7a7ed8cb00b311046e9e91e0fd211e6c2f22b6ebeb69ec22bdda55",
|
||||
|
Loading…
Reference in New Issue
Block a user