def test_cancel_message_via_initialize(client: Client, message): resp = client.call_raw(message) assert isinstance(resp, m.ButtonRequest) client._raw_write(m.ButtonAck()) client._raw_write(m.Initialize()) resp = client._raw_read() assert isinstance(resp, m.Features)
def test_autolock_cancels_ui(client: Client): set_autolock_delay(client, 10 * 1000) resp = client.call_raw( messages.GetAddress( coin_name="Testnet", address_n=TEST_ADDRESS_N, show_display=True, script_type=messages.InputScriptType.SPENDADDRESS, )) assert isinstance(resp, messages.ButtonRequest) # send an ack, do not read response client._raw_write(messages.ButtonAck()) # sleep more than auto-lock delay time.sleep(10.5) resp = client._raw_read() assert isinstance(resp, messages.Failure) assert resp.code == messages.FailureType.ActionCancelled
def test_cancel_on_paginated(client: Client): """Check that device is responsive on paginated screen. See #1708.""" # In #1708, the device would ignore USB (or UDP) events while waiting for the user # to page through the screen. This means that this testcase, instead of failing, # would get stuck waiting for the _raw_read result. # I'm not spending the effort to modify the testcase to cause a _failure_ if that # happens again. Just be advised that this should not get stuck. message = m.SignMessage( message=b"hello" * 64, address_n=TEST_ADDRESS_N, coin_name="Testnet", ) resp = client.call_raw(message) assert isinstance(resp, m.ButtonRequest) client._raw_write(m.ButtonAck()) client.debug.press_yes() resp = client._raw_read() assert isinstance(resp, m.ButtonRequest) assert resp.pages is not None client._raw_write(m.ButtonAck()) client._raw_write(m.Cancel()) resp = client._raw_read() assert isinstance(resp, m.Failure) assert resp.code == m.FailureType.ActionCancelled