diff options
author | Florian Dold <florian@dold.me> | 2021-02-16 11:34:50 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-02-16 13:47:01 +0100 |
commit | db59275b6b43f8fa7f36899ae81cb7139a2e80cb (patch) | |
tree | 66ef429005a0ab239a212c39ad4501b29f727f97 /packages/idb-bridge/src/MemoryBackend.ts | |
parent | d1f00aeaa26af6835ea3f47ac280b1e67d672fa2 (diff) | |
download | wallet-core-db59275b6b43f8fa7f36899ae81cb7139a2e80cb.tar.xz |
add more tests and fix various issues
Diffstat (limited to 'packages/idb-bridge/src/MemoryBackend.ts')
-rw-r--r-- | packages/idb-bridge/src/MemoryBackend.ts | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/packages/idb-bridge/src/MemoryBackend.ts b/packages/idb-bridge/src/MemoryBackend.ts index 2b4437bcf..9a9527729 100644 --- a/packages/idb-bridge/src/MemoryBackend.ts +++ b/packages/idb-bridge/src/MemoryBackend.ts @@ -29,7 +29,6 @@ import { } from "./backend-interface"; import { structuredClone, - structuredEncapsulate, structuredRevive, } from "./util/structuredClone"; import { @@ -39,12 +38,11 @@ import { DataError, } from "./util/errors"; import BTree, { ISortedMapF } from "./tree/b+tree"; -import compareKeys from "./util/cmp"; +import { compareKeys } from "./util/cmp"; import { StoreKeyResult, makeStoreKeyValue } from "./util/makeStoreKeyValue"; -import getIndexKeys from "./util/getIndexKeys"; -import openPromise from "./util/openPromise"; +import { getIndexKeys } from "./util/getIndexKeys"; +import { openPromise } from "./util/openPromise"; import { - IDBKeyPath, IDBKeyRange, IDBTransactionMode, IDBValidKey, @@ -1440,7 +1438,7 @@ export class MemoryBackend implements Backend { const hasKey = modifiedData.has(key); if (hasKey && storeReq.storeLevel !== StoreLevel.AllowOverwrite) { - throw Error("refusing to overwrite"); + throw new ConstraintError("refusing to overwrite"); } } @@ -1537,7 +1535,7 @@ export class MemoryBackend implements Backend { } const myConn = this.connectionsByTransaction[btx.transactionCookie]; if (!myConn) { - throw Error("unknown connection"); + throw Error("unknown transaction"); } const db = this.databases[myConn.dbName]; if (!db) { @@ -1626,5 +1624,3 @@ export class MemoryBackend implements Backend { } } } - -export default MemoryBackend; |