def _check_pin(client: Client, pin): client.lock() with client: client.use_pin_sequence([pin]) client.set_expected_responses( [messages.PinMatrixRequest, messages.Address]) get_test_address(client)
def _check_no_pin(client: Client): client.lock() assert client.features.pin_protection is False with client: client.set_expected_responses([messages.Address]) btc.get_address(client, "Testnet", PASSPHRASE_TEST_PATH)
def _check_pin(client: Client, pin): client.lock() assert client.features.pin_protection is True assert client.features.unlocked is False with client: client.use_pin_sequence([pin]) client.set_expected_responses( [messages.ButtonRequest, messages.Address]) btc.get_address(client, "Testnet", PASSPHRASE_TEST_PATH)
def test_experimental_features(client: Client): def experimental_call(): btc.authorize_coinjoin( client, coordinator="www.example.com", max_rounds=10, max_coordinator_fee_rate=50_000_000, # 0.5 % max_fee_per_kvbyte=3500, n=parse_path("m/84h/1h/0h"), coin_name="Testnet", script_type=messages.InputScriptType.SPENDWITNESS, ) assert client.features.experimental_features is None # unlock with client: _set_expected_responses(client) device.apply_settings(client, label="new label") assert client.features.experimental_features with client: client.set_expected_responses( [messages.ButtonRequest, messages.ButtonRequest, messages.Success] ) experimental_call() # relock and try again client.lock() with client: client.use_pin_sequence([PIN4]) client.set_expected_responses( [ messages.ButtonRequest, messages.ButtonRequest, messages.ButtonRequest, messages.Success, ] ) experimental_call() # unset experimental features with client: client.set_expected_responses([messages.Success, messages.Features]) device.apply_settings(client, experimental_features=False) assert not client.features.experimental_features with pytest.raises(exceptions.TrezorFailure, match="DataError"), client: client.set_expected_responses([messages.Failure]) experimental_call()
def test_passphrase_reporting(client: Client, passphrase): """On TT, passphrase_protection is a private setting, so a locked device should report passphrase_protection=None. """ with client: client.use_pin_sequence([PIN4]) device.apply_settings(client, use_passphrase=passphrase) client.lock() # on a locked device, passphrase_protection should be None assert client.features.unlocked is False assert client.features.passphrase_protection is None # on an unlocked device, protection should be reported accurately _assert_protection(client, pin=True, passphrase=passphrase) # after re-locking, the setting should be hidden again client.lock() assert client.features.unlocked is False assert client.features.passphrase_protection is None
def _check_no_pin(client: Client): client.lock() with client: client.set_expected_responses([messages.Address]) get_test_address(client)