aboutsummaryrefslogtreecommitdiff
path: root/packages/idb-bridge
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-10-15 16:03:48 +0200
committerFlorian Dold <florian@dold.me>2022-10-15 16:03:48 +0200
commita41d1ee53e1dc6af0b54f085053278e039cda8dc (patch)
tree5b6200a0cfa067c0d27743b9c6c94ceaa2efcd10 /packages/idb-bridge
parentbd88dcebbcf90414c790a86ee13740eaf20e3334 (diff)
wallet-core: put signing keys in separate object store
Diffstat (limited to 'packages/idb-bridge')
-rw-r--r--packages/idb-bridge/src/MemoryBackend.test.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/idb-bridge/src/MemoryBackend.test.ts b/packages/idb-bridge/src/MemoryBackend.test.ts
index b36143aa2..8a544a201 100644
--- a/packages/idb-bridge/src/MemoryBackend.test.ts
+++ b/packages/idb-bridge/src/MemoryBackend.test.ts
@@ -26,6 +26,7 @@ import {
import {
IDBCursorDirection,
IDBCursorWithValue,
+ IDBDatabase,
IDBKeyRange,
IDBValidKey,
} from "./idbtypes.js";
@@ -439,6 +440,45 @@ test("update with non-existent index values", async (t) => {
t.pass();
});
+test("delete from unique index", async (t) => {
+ const backend = new MemoryBackend();
+ backend.enableTracing = true;
+ const idb = new BridgeIDBFactory(backend);
+ const request = idb.open("mydb");
+ request.onupgradeneeded = () => {
+ const db = request.result as IDBDatabase;
+ const store = db.createObjectStore("bla", { keyPath: "x" });
+ store.createIndex("by_yz", ["y", "z"], {
+ unique: true,
+ });
+ };
+
+ const db: BridgeIDBDatabase = await promiseFromRequest(request);
+
+ t.is(db.name, "mydb");
+
+ {
+ const tx = db.transaction("bla", "readwrite");
+ const store = tx.objectStore("bla");
+ store.put({ x: 0, y: "a", z: 42 });
+ const index = store.index("by_yz");
+ const indRes = await promiseFromRequest(index.get(["a", 42]));
+ t.is(indRes.x, 0);
+ const res = await promiseFromRequest(store.get(0));
+ t.is(res.z, 42);
+ await promiseFromTransaction(tx);
+ }
+
+ {
+ const tx = db.transaction("bla", "readwrite");
+ const store = tx.objectStore("bla");
+ store.put({ x: 0, y: "a", z: 42, extra: 123 });
+ await promiseFromTransaction(tx);
+ }
+
+ t.pass();
+});
+
test("range queries", async (t) => {
const backend = new MemoryBackend();
backend.enableTracing = true;