diff options
author | Florian Dold <florian@dold.me> | 2021-06-10 10:37:49 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-06-10 10:37:49 +0200 |
commit | 7b7e3b4565169835ad04062d5c76ba655abd770a (patch) | |
tree | a6fe6ade0852d85e91410d57f52c18cb6c547197 /packages | |
parent | 67e5d68b9309c6d35a92bb052879c41854b2ea73 (diff) |
transaction fixes
Diffstat (limited to 'packages')
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 58cec8673..ecabfbc7a 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 1dfbe4dba..5197967b8 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-payment-multiple.ts @@ -83,17 +83,17 @@ async function setupTest( 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 f6aad31ca..cf1eded12 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-revocation.ts @@ -118,17 +118,17 @@ async function createTestEnvironment( 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 a1a0defb7..3f26aaf0d 100644 --- a/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts +++ b/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts @@ -115,17 +115,17 @@ export async function runTimetravelAutorefreshTest(t: GlobalTestState) { 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 b6bab02c5..d02ea192f 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 ab5a1fc7a..cf3f791d5 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); |