transaction fixes
This commit is contained in:
parent
67e5d68b93
commit
7b7e3b4565
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user