|
4 | 4 | from application_client.boilerplate_command_sender import BoilerplateCommandSender, Errors
|
5 | 5 | from application_client.boilerplate_response_unpacker import unpack_get_public_key_response, unpack_sign_tx_response
|
6 | 6 | from ragger.error import ExceptionRAPDU
|
| 7 | +from ragger.navigator import NavInsID |
7 | 8 | from utils import check_signature_validity
|
8 | 9 |
|
9 | 10 | # In this tests we check the behavior of the device when asked to sign a transaction
|
10 | 11 |
|
11 | 12 |
|
12 |
| -# In this test se send to the device a transaction to sign and validate it on screen |
| 13 | +# In this test we send to the device a transaction to sign and validate it on screen |
13 | 14 | # The transaction is short and will be sent in one chunk
|
14 | 15 | # We will ensure that the displayed information is correct by using screenshots comparison
|
15 | 16 | def test_sign_tx_short_tx(backend, scenario_navigator):
|
@@ -43,6 +44,47 @@ def test_sign_tx_short_tx(backend, scenario_navigator):
|
43 | 44 | assert check_signature_validity(public_key, der_sig, transaction)
|
44 | 45 |
|
45 | 46 |
|
| 47 | +# In this test we send to the device a transaction to trig a blind-signing flow |
| 48 | +# The transaction is short and will be sent in one chunk |
| 49 | +# We will ensure that the displayed information is correct by using screenshots comparison |
| 50 | +def test_sign_tx_short_tx_blind_sign(firmware, navigator, backend, scenario_navigator, test_name, default_screenshot_path): |
| 51 | + if firmware.is_nano: |
| 52 | + pytest.skip("Not supported on Nano devices") |
| 53 | + |
| 54 | + # Use the app interface instead of raw interface |
| 55 | + client = BoilerplateCommandSender(backend) |
| 56 | + # The path used for this entire test |
| 57 | + path: str = "m/44'/1'/0'/0/0" |
| 58 | + |
| 59 | + # First we need to get the public key of the device in order to build the transaction |
| 60 | + rapdu = client.get_public_key(path=path) |
| 61 | + _, public_key, _, _ = unpack_get_public_key_response(rapdu.data) |
| 62 | + |
| 63 | + # Create the transaction that will be sent to the device for signing |
| 64 | + transaction = Transaction( |
| 65 | + nonce=1, |
| 66 | + to="0x0000000000000000000000000000000000000000", |
| 67 | + value=0, |
| 68 | + memo="Blind-sign" |
| 69 | + ).serialize() |
| 70 | + |
| 71 | + # Send the sign device instruction. |
| 72 | + # As it requires on-screen validation, the function is asynchronous. |
| 73 | + # It will yield the result when the navigation is done |
| 74 | + with client.sign_tx(path=path, transaction=transaction): |
| 75 | + navigator.navigate_and_compare(default_screenshot_path, |
| 76 | + test_name+"/part1", |
| 77 | + [NavInsID.USE_CASE_CHOICE_REJECT], |
| 78 | + screen_change_after_last_instruction=False) |
| 79 | + |
| 80 | + # Validate the on-screen request by performing the navigation appropriate for this device |
| 81 | + scenario_navigator.review_approve() |
| 82 | + |
| 83 | + # The device as yielded the result, parse it and ensure that the signature is correct |
| 84 | + response = client.get_async_response().data |
| 85 | + _, der_sig, _ = unpack_sign_tx_response(response) |
| 86 | + assert check_signature_validity(public_key, der_sig, transaction) |
| 87 | + |
46 | 88 | # In this test se send to the device a transaction to sign and validate it on screen
|
47 | 89 | # This test is mostly the same as the previous one but with different values.
|
48 | 90 | # In particular the long memo will force the transaction to be sent in multiple chunks
|
|
0 commit comments