Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulmth committed Oct 26, 2023
1 parent 31eb3b3 commit 851356d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bindings/wasm/tests/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ describe("#OptionParsing", function() {
});
});

describe("#documents throw error on concurrent access", async function() {
describe("#Documents throw error on concurrent synchronous access", async function() {
const wait: any = (ms: any) => new Promise(r => setTimeout(r, ms));

class MyJwkStore extends JwkMemStore {
Expand Down Expand Up @@ -501,11 +501,14 @@ describe("#documents throw error on concurrent access", async function() {
return document.id();
});

let resolvedToError = false;
try {
await Promise.all([insertPromise, idPromise]);
} catch (e: any) {
resolvedToError = true;
assert.equal(e.name, "TryLockError");
}
assert.ok(resolvedToError, "Promise.all did not throw an error");
});

it("IotaDocument", async () => {
Expand All @@ -522,11 +525,13 @@ describe("#documents throw error on concurrent access", async function() {
const idPromise = wait(10).then((_value: any) => {
return document.id();
});

let resolvedToError = false;
try {
await Promise.all([insertPromise, idPromise]);
} catch (e: any) {
resolvedToError = true;
assert.equal(e.name, "TryLockError");
}
assert.ok(resolvedToError, "Promise.all did not throw an error");
});
});

0 comments on commit 851356d

Please sign in to comment.