From 77b931e217258f235f5c63cea09542512479cb71 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Mon, 3 Aug 2020 18:27:53 +0200 Subject: [PATCH] tests: Add device test for CancelAuthorization message. --- .../test_msg_authorize_coinjoin.py | 28 ++++++++++++++++++- tests/ui_tests/fixtures.json | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/tests/device_tests/test_msg_authorize_coinjoin.py b/tests/device_tests/test_msg_authorize_coinjoin.py index 9e6ec91fe9..a2d03410d6 100644 --- a/tests/device_tests/test_msg_authorize_coinjoin.py +++ b/tests/device_tests/test_msg_authorize_coinjoin.py @@ -16,7 +16,7 @@ import pytest -from trezorlib import btc, messages +from trezorlib import btc, device, messages from trezorlib.exceptions import TrezorFailure from trezorlib.tools import parse_path @@ -389,3 +389,29 @@ def test_wrong_coordinator(client): commitment_data=b"www.example.org" + (1).to_bytes(ROUND_ID_LEN, "big"), preauthorized=True, ) + + +def test_cancel_authorization(client): + # Ensure that a preauthorized GetOwnershipProof fails if the commitment_data doesn't match the coordinator. + + btc.authorize_coinjoin( + client, + max_total_fee=50000, + coordinator="www.example.com", + n=parse_path("m/84'/1'/0'"), + coin_name="Testnet", + script_type=messages.InputScriptType.SPENDWITNESS, + ) + + device.cancel_authorization(client) + + with pytest.raises(TrezorFailure, match="No preauthorized operation"): + ownership_proof, _ = btc.get_ownership_proof( + client, + "Testnet", + parse_path("84'/1'/0'/1/0"), + script_type=messages.InputScriptType.SPENDWITNESS, + user_confirmation=True, + commitment_data=b"www.example.com" + (1).to_bytes(ROUND_ID_LEN, "big"), + preauthorized=True, + ) diff --git a/tests/ui_tests/fixtures.json b/tests/ui_tests/fixtures.json index 39618aafec..8a5309d345 100644 --- a/tests/ui_tests/fixtures.json +++ b/tests/ui_tests/fixtures.json @@ -15,6 +15,7 @@ "test_msg_applysettings.py-test_apply_settings_passphrase": "5c1ed9a0be3d14475102d447da0b5d51bbb6dfaaeceff5ea9179064609db7870", "test_msg_applysettings.py-test_apply_settings_passphrase_on_device": "3e6527e227bdde54f51bc9c417b176d0d87fdb6c40c4761368f50eb201b4beed", "test_msg_applysettings.py-test_safety_checks": "19bd500c3b791d51bbd1140085f306a838194593697529263f362acb0b1ab445", +"test_msg_authorize_coinjoin.py::test_cancel_authorization": "d8a608beb6165f5667cc44dcff6bdc17ebb4638ddd3bd09e7f0e1e75d1e21135", "test_msg_authorize_coinjoin.py::test_no_anonymity": "fd09da284b650e893990b95047b63a35b6b695fc5301d595f17a6d2cf9d90bcb", "test_msg_authorize_coinjoin.py::test_sign_tx": "2838d4062333c241b6bbef7e680ec8a5764fe7bcaa41419e4141e146d3586a5d", "test_msg_authorize_coinjoin.py::test_unfair_fee": "62314e936de46a6caaf02c8eb20f6f471be6e79ca0c5450cad6f67f9cb823f2b",