Skip to content

Commit

Permalink
Fix issue in IndexedDB payload driver, other tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sgwilym committed May 1, 2024
1 parent eb5f120 commit f62e9e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
17 changes: 9 additions & 8 deletions src/store/storage/payload_drivers/indexeddb.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { delay } from "https://deno.land/[email protected]/async/delay.ts";
import { concat, deferred } from "../../../../deps.ts";
import { ValidationError, WillowError } from "../../../errors.ts";
import { Payload, PayloadScheme } from "../../types.ts";
Expand Down Expand Up @@ -198,12 +199,12 @@ export class PayloadDriverIndexedDb<PayloadDigest>
PAYLOAD_STORE,
);

const request = payloadStore.put(bytes, key);

const didSet = deferred<
{ digest: PayloadDigest; length: bigint; payload: Payload }
>();

const request = payloadStore.put(bytes, key);

request.onsuccess = () => {
didSet.resolve({
digest,
Expand Down Expand Up @@ -261,20 +262,20 @@ export class PayloadDriverIndexedDb<PayloadDigest>

const finalBytes = concat(existingBytes, receivedBytes);

const payloadStore2 = db.transaction([PAYLOAD_STORE], "readwrite")
const digest = await this.payloadScheme.fromBytes(
new Uint8Array(finalBytes),
);

const payloadStore = db.transaction([PAYLOAD_STORE], "readwrite")
.objectStore(
PAYLOAD_STORE,
);

const request = payloadStore2.put(finalBytes, key);

const didSet = deferred<
{ digest: PayloadDigest; length: bigint }
>();

const digest = await this.payloadScheme.fromBytes(
new Uint8Array(finalBytes),
);
const request = payloadStore.put(finalBytes, key);

request.onsuccess = () => {
didSet.resolve({
Expand Down
2 changes: 1 addition & 1 deletion src/wgps/encoding.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ Deno.test("Encoding roundtrip test", async () => {
aoiHandlesToRange3d: () => {
return Promise.resolve(defaultRange3d(TestSubspace.Alfie));
},
getCap: (handle) => {
getTheirCap: (handle) => {
if (handle === BigInt(23)) {
return Promise.resolve({
namespace: TestNamespace.Bookclub,
Expand Down
4 changes: 2 additions & 2 deletions src/wgps/wgps_messenger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ const scenarioMemory: WgpsScenario = {
payloadDriver,
});
},
timeMultiplier: 10,
timeMultiplier: 20,
dispose: () => Promise.resolve(),
};

testWgpsMessenger(scenarioMemory);

class ScenarioPersisted implements WgpsScenario {
name = "Filesystem";
timeMultiplier = 50;
timeMultiplier = 80;

kvs: Deno.Kv[] = [];

Expand Down

0 comments on commit f62e9e0

Please sign in to comment.