コード例 #1
0
    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)
コード例 #2
0
 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()
コード例 #3
0
 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')
コード例 #4
0
    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)
コード例 #5
0
 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()
コード例 #6
0
    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')
コード例 #7
0
    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')
コード例 #8
0
    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')
コード例 #9
0
    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')
コード例 #10
0
 def test_initialize(self):
     with self.client:
         self.setup_mnemonic_pin_passphrase()
         self.client.set_expected_responses([proto.Features()])
         self.client.init_device()