Exemplo n.º 1
0
    def test_check_need_confirm_password(self):
        wiz = self.wizard
        storage = WalletStorage(self.wallet_path)
        d = {'wallet_type': 'standard', "seed_version": FINAL_SEED_VERSION}
        d['wallet_type'] = '2of3'
        d['x1/'] = X1_VIEW_ONLY
        d['x2/'] = X2
        db = WalletDB(json.dumps(d), manual_upgrades=True)
        db.write(storage)
        storage = WalletStorage(self.wallet_path)
        wiz.continue_multisig_setup(storage)

        wiz.unfinished_check_password = storage.check_password
        assert wiz.check_need_confirm_password()
        wiz.unfinished_check_password = None
        assert not wiz.check_need_confirm_password()
        wiz.keystores[1].update_password(None, 'test')
        assert wiz.check_need_confirm_password()
Exemplo n.º 2
0
    def test_continue_multisig_setup(self):
        wiz = self.wizard
        storage = WalletStorage(self.wallet_path)
        d = {'wallet_type': 'standard', "seed_version": FINAL_SEED_VERSION}
        d['wallet_type'] = '2of3'
        d['x1/'] = X1
        db = WalletDB(json.dumps(d), manual_upgrades=True)
        assert db.check_unfinished_multisig()
        db.write(storage)
        storage = WalletStorage(self.wallet_path)
        wiz.continue_multisig_setup(storage)
        assert wiz.unfinished_multisig
        assert wiz.unfinished_enc_version == StorageEncryptionVersion.PLAINTEXT
        assert not wiz.unfinished_check_password
        assert wiz.last_method == 'continue_multisig_setup_dialog'
        last_args = wiz.last_args
        assert last_args[0:2] == (2, 3)  # m, n
        assert last_args[2] == wiz.keystores  # keystores
        assert len(last_args[2]) == 1
        k1 = last_args[2][0]
        assert type(k1) == BIP32_KeyStore
        assert k1.get_root_fingerprint() == '3f635a63'
        assert last_args[3] == wiz.choose_keystore  # run_next

        d['x2/'] = X2
        db = WalletDB(json.dumps(d), manual_upgrades=True)
        assert db.check_unfinished_multisig()
        db.write(storage)
        storage = WalletStorage(self.wallet_path)
        wiz.continue_multisig_setup(storage)
        assert wiz.unfinished_multisig
        assert wiz.unfinished_enc_version == StorageEncryptionVersion.PLAINTEXT
        assert not wiz.unfinished_check_password
        assert wiz.last_method == 'continue_multisig_setup_dialog'
        last_args = wiz.last_args
        assert last_args[0:2] == (2, 3)  # m, n
        assert last_args[2] == wiz.keystores  # keystores
        assert len(last_args[2]) == 2
        k1, k2 = last_args[2]
        assert type(k1) == BIP32_KeyStore
        assert k1.get_root_fingerprint() == '3f635a63'
        assert type(k2) == BIP32_KeyStore
        assert k2.get_root_fingerprint() == 'e54b06c8'
        assert last_args[3] == wiz.choose_keystore  # run_next
Exemplo n.º 3
0
    def test_write_dictionary_to_file(self):

        storage = WalletStorage(self.wallet_path)
        db = WalletDB('', manual_upgrades=True)

        some_dict = {
            u"a": u"b",
            u"c": u"d",
            u"seed_version": FINAL_SEED_VERSION}

        for key, value in some_dict.items():
            db.put(key, value)
        db.write(storage)

        with open(self.wallet_path, "r") as f:
            contents = f.read()
        d = json.loads(contents)
        for key, value in some_dict.items():
            self.assertEqual(d[key], value)