[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: transaction fixes
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: transaction fixes |
Date: |
Thu, 10 Jun 2021 10:37:54 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 7b7e3b45 transaction fixes
7b7e3b45 is described below
commit 7b7e3b4565169835ad04062d5c76ba655abd770a
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu Jun 10 10:37:49 2021 +0200
transaction fixes
---
packages/idb-bridge/src/bridge-idb.ts | 19 +++++++++++++------
.../src/integrationtests/test-payment-multiple.ts | 12 ++++++------
.../src/integrationtests/test-revocation.ts | 12 ++++++------
.../integrationtests/test-timetravel-autorefresh.ts | 12 ++++++------
packages/taler-wallet-core/src/db.ts | 19 +++++++++++++++++++
packages/taler-wallet-core/src/util/query.ts | 14 ++++++++++----
6 files changed, 60 insertions(+), 28 deletions(-)
diff --git a/packages/idb-bridge/src/bridge-idb.ts
b/packages/idb-bridge/src/bridge-idb.ts
index 58cec867..ecabfbc7 100644
--- a/packages/idb-bridge/src/bridge-idb.ts
+++ b/packages/idb-bridge/src/bridge-idb.ts
@@ -1201,19 +1201,26 @@ export class BridgeIDBIndex implements IDBIndex {
private _confirmIndexExists() {
const storeSchema = this._schema.objectStores[this._objectStore._name];
if (!storeSchema) {
- throw new InvalidStateError();
+ throw new InvalidStateError(
+ `no schema for object store '${this._objectStore._name}'`,
+ );
}
if (!storeSchema.indexes[this._name]) {
- throw new InvalidStateError();
+ throw new InvalidStateError(
+ `no schema for index '${this._name}' of object store
'${this._objectStore._name}'`,
+ );
}
}
get(key: BridgeIDBKeyRange | IDBValidKey) {
- this._confirmIndexExists();
- this._confirmActiveTransaction();
if (this._deleted) {
throw new InvalidStateError();
}
+ if (this._objectStore._deleted) {
+ throw new InvalidStateError();
+ }
+ this._confirmActiveTransaction();
+ this._confirmIndexExists();
if (!(key instanceof BridgeIDBKeyRange)) {
key = BridgeIDBKeyRange._valueToKeyRange(key);
@@ -1595,10 +1602,10 @@ export class BridgeIDBObjectStore implements
IDBObjectStore {
*/
_confirmActiveTransaction(): void {
if (!this._transaction._active) {
- throw new TransactionInactiveError();
+ throw new TransactionInactiveError("transaction is not active");
}
if (this._transaction._aborted) {
- throw new TransactionInactiveError();
+ throw new TransactionInactiveError("transaction has been aborted");
}
}
diff --git
a/packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts
b/packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts
index 1dfbe4db..5197967b 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts
@@ -82,18 +82,18 @@ async function setupTest(
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
- id: "minst1",
- name: "minst1",
- paytoUris: ["payto://x-taler-bank/minst1"],
- });
-
await merchant.addInstance({
id: "default",
name: "Default Instance",
paytoUris: [`payto://x-taler-bank/merchant-default`],
});
+ await merchant.addInstance({
+ id: "minst1",
+ name: "minst1",
+ paytoUris: ["payto://x-taler-bank/minst1"],
+ });
+
console.log("setup done!");
return {
diff --git a/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts
b/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts
index f6aad31c..cf1eded1 100644
--- a/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts
@@ -117,18 +117,18 @@ async function createTestEnvironment(
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
- id: "minst1",
- name: "minst1",
- paytoUris: ["payto://x-taler-bank/minst1"],
- });
-
await merchant.addInstance({
id: "default",
name: "Default Instance",
paytoUris: [`payto://x-taler-bank/merchant-default`],
});
+ await merchant.addInstance({
+ id: "minst1",
+ name: "minst1",
+ paytoUris: ["payto://x-taler-bank/minst1"],
+ });
+
console.log("setup done!");
const wallet = new WalletCli(t);
diff --git
a/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts
b/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts
index a1a0defb..3f26aaf0 100644
---
a/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts
+++
b/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts
@@ -114,18 +114,18 @@ export async function runTimetravelAutorefreshTest(t:
GlobalTestState) {
await merchant.start();
await merchant.pingUntilAvailable();
- await merchant.addInstance({
- id: "minst1",
- name: "minst1",
- paytoUris: ["payto://x-taler-bank/minst1"],
- });
-
await merchant.addInstance({
id: "default",
name: "Default Instance",
paytoUris: [`payto://x-taler-bank/merchant-default`],
});
+ await merchant.addInstance({
+ id: "minst1",
+ name: "minst1",
+ paytoUris: ["payto://x-taler-bank/minst1"],
+ });
+
console.log("setup done!");
const wallet = new WalletCli(t);
diff --git a/packages/taler-wallet-core/src/db.ts
b/packages/taler-wallet-core/src/db.ts
index b6bab02c..d02ea192 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -1,3 +1,22 @@
+/*
+ This file is part of GNU Taler
+ (C) 2021 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+/**
+ * Imports.
+ */
import {
openDatabase,
describeStore,
diff --git a/packages/taler-wallet-core/src/util/query.ts
b/packages/taler-wallet-core/src/util/query.ts
index ab5a1fc7..cf3f791d 100644
--- a/packages/taler-wallet-core/src/util/query.ts
+++ b/packages/taler-wallet-core/src/util/query.ts
@@ -454,8 +454,11 @@ function makeReadContext(
const indexes: { [s: string]: IndexReadOnlyAccessor<any> } = {};
const swi = storePick[storeAlias];
const storeName = swi.store.name;
- for (const indexName in storePick[storeAlias].indexMap) {
- indexes[indexName] = {
+ for (const indexAlias in storePick[storeAlias].indexMap) {
+ const indexDescriptor: IndexDescriptor =
+ storePick[storeAlias].indexMap[indexAlias];
+ const indexName = indexDescriptor.name;
+ indexes[indexAlias] = {
get(key) {
const req = tx.objectStore(storeName).index(indexName).get(key);
return requestToPromise(req);
@@ -493,8 +496,11 @@ function makeWriteContext(
const indexes: { [s: string]: IndexReadWriteAccessor<any> } = {};
const swi = storePick[storeAlias];
const storeName = swi.store.name;
- for (const indexName in storePick[storeAlias].indexMap) {
- indexes[indexName] = {
+ for (const indexAlias in storePick[storeAlias].indexMap) {
+ const indexDescriptor: IndexDescriptor =
+ storePick[storeAlias].indexMap[indexAlias];
+ const indexName = indexDescriptor.name;
+ indexes[indexAlias] = {
get(key) {
const req = tx.objectStore(storeName).index(indexName).get(key);
return requestToPromise(req);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: transaction fixes,
gnunet <=