[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: idb: fix test / backend
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: idb: fix test / backend |
Date: |
Tue, 23 Feb 2021 21:30:17 +0100 |
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 627ae695 idb: fix test / backend
627ae695 is described below
commit 627ae6958ef9b98fc16f129fdf95435a5e95b738
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Feb 23 21:30:11 2021 +0100
idb: fix test / backend
---
packages/idb-bridge/src/bridge-idb.ts | 48 ++++------------------
.../idbcursor-continue-objectstore.test.ts | 5 ++-
.../idbcursor-delete-exception-order.test.ts | 9 ++--
.../idb-wpt-ported/idbcursor-update-index.test.ts | 3 +-
4 files changed, 19 insertions(+), 46 deletions(-)
diff --git a/packages/idb-bridge/src/bridge-idb.ts
b/packages/idb-bridge/src/bridge-idb.ts
index 3c168674..0c309b42 100644
--- a/packages/idb-bridge/src/bridge-idb.ts
+++ b/packages/idb-bridge/src/bridge-idb.ts
@@ -205,6 +205,7 @@ export class BridgeIDBCursor implements IDBCursor {
);
BridgeIDBFactory.enableTracing &&
console.log("cursor type ", this.toString());
+ const isIndex = this._indexName !== undefined;
const recordGetRequest: RecordGetRequest = {
direction: this.direction,
indexName: this._indexName,
@@ -213,8 +214,8 @@ export class BridgeIDBCursor implements IDBCursor {
limit: 1,
range: simplifyRange(this._range),
objectStoreName: this._objectStoreName,
- advanceIndexKey: key,
- advancePrimaryKey: primaryKey,
+ advanceIndexKey: isIndex ? key : undefined,
+ advancePrimaryKey: isIndex ? primaryKey : key,
resultLevel: this._keyOnly ? ResultLevel.OnlyKeys : ResultLevel.Full,
};
@@ -1113,12 +1114,7 @@ export class BridgeIDBIndex implements IDBIndex {
this._confirmActiveTransaction();
- if (range === null) {
- range = undefined;
- }
- if (range !== undefined && !(range instanceof BridgeIDBKeyRange)) {
- range = BridgeIDBKeyRange.only(valueToKey(range));
- }
+ range = simplifyRange(range);
const request = new BridgeIDBRequest();
request._source = this;
@@ -1793,10 +1789,6 @@ export class BridgeIDBObjectStore implements
IDBObjectStore {
console.log(`getting from object store ${this._name} key ${query}`);
}
- if (arguments.length === 0) {
- throw new TypeError();
- }
-
if (!this._transaction._active) {
throw new TransactionInactiveError();
}
@@ -1811,19 +1803,7 @@ export class BridgeIDBObjectStore implements
IDBObjectStore {
count = -1;
}
- let keyRange: BridgeIDBKeyRange;
-
- if (query instanceof BridgeIDBKeyRange) {
- keyRange = query;
- } else {
- try {
- keyRange = BridgeIDBKeyRange.only(valueToKey(query));
- } catch (e) {
- throw new DataError(
- `invalid key (type ${typeof query}) for object store
'${this._name}'`,
- );
- }
- }
+ let keyRange: BridgeIDBKeyRange | null = simplifyRange(query);
const recordRequest: RecordGetRequest = {
objectStoreName: this._name,
@@ -1877,19 +1857,7 @@ export class BridgeIDBObjectStore implements
IDBObjectStore {
);
}
- let keyRange: BridgeIDBKeyRange;
-
- if (query instanceof BridgeIDBKeyRange) {
- keyRange = query;
- } else {
- try {
- keyRange = BridgeIDBKeyRange.only(valueToKey(query));
- } catch (e) {
- throw new DataError(
- `invalid key (type ${typeof query}) for object store
'${this._name}'`,
- );
- }
- }
+ let keyRange: BridgeIDBKeyRange | null = simplifyRange(query);
const recordRequest: RecordGetRequest = {
objectStoreName: this._name,
@@ -1904,13 +1872,13 @@ export class BridgeIDBObjectStore implements
IDBObjectStore {
const operation = async () => {
if (BridgeIDBFactory.enableTracing) {
- console.log("running get operation:", recordRequest);
+ console.log("running getKey operation:", recordRequest);
}
const { btx } = this._confirmStartedBackendTransaction();
const result = await this._backend.getRecords(btx, recordRequest);
if (BridgeIDBFactory.enableTracing) {
- console.log("get operation result count:", result.count);
+ console.log("getKey operation result count:", result.count);
}
if (result.count === 0) {
diff --git
a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-objectstore.test.ts
b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-objectstore.test.ts
index ecfac82f..4843b13a 100644
---
a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-objectstore.test.ts
+++
b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-continue-objectstore.test.ts
@@ -112,7 +112,8 @@ test.cb("WPT test idbcursor_continue_objectstore3.htm", (t)
=> {
};
});
-// IDBCursor.continue() - object store - attempt to iterate to the next record
when the direction is set for the previous record
+// IDBCursor.continue() - object store - attempt to iterate to the
+// next record when the direction is set for the previous record
test.cb("WPT test idbcursor_continue_objectstore4.htm", (t) => {
var db: any;
const records = [
@@ -151,7 +152,9 @@ test.cb("WPT test idbcursor_continue_objectstore4.htm", (t)
=> {
t.deepEqual(cursor.value.pKey, records[1].pKey, "second cursor
pkey");
t.throws(
() => {
+ console.log("**** continuing cursor");
cursor.continue(records[2].pKey);
+ console.log("**** this should not happen");
},
{
name: "DataError",
diff --git
a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-exception-order.test.ts
b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-exception-order.test.ts
index c80e276e..604061ac 100644
---
a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-exception-order.test.ts
+++
b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-delete-exception-order.test.ts
@@ -18,9 +18,10 @@ test("WPT idbcursor-delete-exception-order.htm", async (t)
=> {
const cursor = r.result;
t.assert(!!cursor);
t.throws(
- () => {},
+ () => {
+ cursor!.delete();
+ },
{ name: "TransactionInactiveError" },
-
'"Transaction inactive" check (TransactionInactivError) ' +
'should precede "read only" check (ReadOnlyError)',
);
@@ -72,7 +73,9 @@ test("WPT idbcursor-delete-exception-order.htm", async (t) =>
{
r.onsuccess = null;
const cursor = r.result;
t.throws(
- () => {},
+ () => {
+ cursor!.delete();
+ },
{ name: "ReadOnlyError" },
'"Read only" check (ReadOnlyError) should precede ' +
'"key only flag" (InvalidStateError) check',
diff --git
a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-update-index.test.ts
b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-update-index.test.ts
index 950a31e3..363ef4af 100644
--- a/packages/idb-bridge/src/idb-wpt-ported/idbcursor-update-index.test.ts
+++ b/packages/idb-bridge/src/idb-wpt-ported/idbcursor-update-index.test.ts
@@ -202,8 +202,7 @@ test.cb("WPT test idbcursor_update_index5.htm", (t) => {
var record = cursor.value;
// Original test uses different uncloneable value
- record.data = { foo: "42" };
- record.data.me = record.data;
+ record.data = { foo: () => {} };
t.throws(
function () {
cursor.update(record);
--
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: idb: fix test / backend,
gnunet <=