def test_apply_settings_passphrase(self): self.setup_mnemonic_pin_nopassphrase() self.assertEqual(self.client.features.passphrase_protection, False) with self.client: self.client.set_expected_responses( [proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.apply_settings(use_passphrase=True) self.assertEqual(self.client.features.passphrase_protection, True) with self.client: self.client.set_expected_responses( [proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.apply_settings(use_passphrase=False) self.assertEqual(self.client.features.passphrase_protection, False) with self.client: self.client.set_expected_responses( [proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.apply_settings(use_passphrase=True) self.assertEqual(self.client.features.passphrase_protection, True)
def test_wipe_device(self): with self.client: self.setup_mnemonic_pin_passphrase() self.client.set_expected_responses([proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.wipe_device()
def test_apply_settings(self): with self.client: self.setup_mnemonic_pin_passphrase() self.client.clear_session() self.client.set_expected_responses([proto.ButtonRequest(), proto.PinMatrixRequest(), proto.Success(), proto.Features()]) # KeepKeyClient reinitializes device self.client.apply_settings(label='nazdar')
def test_load_device(self): with self.client: self.client.set_expected_responses([proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.load_device_by_mnemonic('this is mnemonic', '1234', True, 'label', 'english', skip_checksum=True) # This must fail, because device is already initialized self.assertRaises(Exception, self.client.load_device_by_mnemonic, 'this is mnemonic', '1234', True, 'label', 'english', skip_checksum=True)
def test_change_pin(self): with self.client: self.setup_mnemonic_pin_passphrase() self.client.set_expected_responses([proto.ButtonRequest(), proto.PinMatrixRequest(), proto.PinMatrixRequest(), proto.PinMatrixRequest(), proto.Success(), proto.Features()]) self.client.change_pin()
def test_recovery_device(self): with self.client: self.client.set_mnemonic(self.mnemonic12) self.client.set_expected_responses([proto.WordRequest()] * 24 + \ [proto.Success(), proto.Features()]) self.client.recovery_device(True, 12, False, False, 'label', 'english') # This must fail, because device is already initialized self.assertRaises(Exception, self.client.recovery_device, 12, False, False, 'label', 'english')
def test_reset_device(self): with self.client: self.client.set_expected_responses([proto.EntropyRequest(), \ proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.reset_device(False, 128, True, False, 'label', 'english') # This must fail, because device is already initialized self.assertRaises(Exception, self.client.reset_device, False, 128, True, False, 'label', 'english')
def test_apply_settings(self): self.setup_mnemonic_pin_passphrase() self.assertEqual(self.client.features.label, 'test') with self.client: self.client.set_expected_responses( [proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.apply_settings(label='new label') self.assertEqual(self.client.features.label, 'new label')
def test_invalid_language(self): self.setup_mnemonic_pin_passphrase() self.assertEqual(self.client.features.language, 'english') with self.client: self.client.set_expected_responses( [proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.apply_settings(language='nonexistent') self.assertEqual(self.client.features.language, 'english')
def test_initialize(self): with self.client: self.setup_mnemonic_pin_passphrase() self.client.set_expected_responses([proto.Features()]) self.client.init_device()