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

test(core): make sure path check fails immediately

This commit is contained in:
Martin Milata 2021-12-14 13:57:56 +01:00
parent e6da3ceb7b
commit bfe5b6a272
3 changed files with 54 additions and 0 deletions

View File

@ -25,11 +25,15 @@ from ..signtx import request_finished, request_input, request_meta, request_outp
B = messages.ButtonRequestType
TX_CACHE_MAINNET = TxCache("Bitcoin")
TX_CACHE_TESTNET = TxCache("Testnet")
TX_CACHE_BCASH = TxCache("Bcash")
TXHASH_8cc1f4 = bytes.fromhex(
"8cc1f4adf7224ce855cf535a5104594a0004cb3b640d6714fdb00b9128832dd5"
)
TXHASH_a5cd2a = bytes.fromhex(
"a5cd2a706d680587e572df16a8ce5233139a094ebbd148cc66a8004dcc88819c"
)
TXHASH_d5f65e = bytes.fromhex(
"d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882"
)
@ -215,3 +219,30 @@ def test_attack_path_segwit(client):
)
btc.sign_tx(client, "Testnet", [inp1, inp2], [out1], prev_txes=TX_CACHE_MAINNET)
@pytest.mark.skip_t1(reason="T1 only prevents using paths known to be altcoins")
def test_invalid_path_fail_asap(client):
inp1 = messages.TxInputType(
address_n=parse_path("0"),
amount=4977040,
prev_hash=TXHASH_a5cd2a,
prev_index=0,
script_type=messages.InputScriptType.SPENDWITNESS,
sequence=4294967293,
)
out1 = messages.TxOutputType(
address_n=parse_path("84h/0h/0h/1/0"),
amount=4977040,
script_type=messages.OutputScriptType.PAYTOWITNESS,
)
with client:
client.set_expected_responses(
[request_input(0), messages.Failure(code=messages.FailureType.DataError)]
)
try:
btc.sign_tx(client, "Testnet", [inp1], [out1], prev_txes=TX_CACHE_TESTNET)
except TrezorFailure:
pass

View File

@ -0,0 +1,22 @@
{
"bin_outputs": [
{
"amount": 4977040,
"script_pubkey": "0014820d4a343a44e915c36494995c2899abe3741893"
},
{
"amount": 0,
"script_pubkey": "6a24aa21a9ed6edfd0a9431aad16549cf318c0d1d237e6a0a87a6403f177caa74fe05546a98f"
}
],
"inputs": [
{
"prev_hash": "0000000000000000000000000000000000000000000000000000000000000000",
"prev_index": 4294967295,
"script_sig": "030c15203a205468697320626c6f636b20776173206d696e65642077697468206120636172626f6e206e6567617469766520706f77657220736f75726365201209687a200909200901b34d00641f8d000000",
"sequence": 4294967295
}
],
"lock_time": 0,
"version": 1
}

View File

@ -290,6 +290,7 @@
"bitcoin-test_signtx_external.py::test_p2wsh_external_presigned": "864fb0b756bef195c9140dc9d1d4878a801c709b880fa38c703ca8438adfedb8",
"bitcoin-test_signtx_invalid_path.py::test_attack_path_segwit": "3feaa01d47aa9757e9d74f668927fd1445493c367adff94215405eb8e0a2749b",
"bitcoin-test_signtx_invalid_path.py::test_invalid_path_fail": "1c100ce4b7c1e47e72428f390de0846c1ff933e9f07894872644a369a9422738",
"bitcoin-test_signtx_invalid_path.py::test_invalid_path_fail_asap": "1c100ce4b7c1e47e72428f390de0846c1ff933e9f07894872644a369a9422738",
"bitcoin-test_signtx_invalid_path.py::test_invalid_path_pass_forkid": "ef98eb752ec5fa948c952def7599f57a2bc5240b2d6b1eec0e02cc9be5c3040f",
"bitcoin-test_signtx_invalid_path.py::test_invalid_path_prompt": "12e137210397357ed754af0f4618ef03312b3e884930f55727d1b034f969bfd5",
"bitcoin-test_signtx_mixed_inputs.py::test_non_segwit_segwit_inputs": "34cbf0075c03f13db8285b0ca9fd3e32dc3380ef95116d873754ec10c9801b99",