-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Datawallet modifications are not executed in the right order and wron…
…g objects are deleted (#278) * test: add negative test * chore: remove unnecessary line * fix: update DatawalletModificationsProcessor to run modifications in correct order * fix: re-add simulateCacheChangeForCreate * chore: naming * fix: change cache order for messages * chore: less space for comments * chore: PR comments * chore: typo * chore: test name --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3edf676
commit 961b560
Showing
3 changed files
with
115 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/transport/test/modules/sync/SyncController.ordered.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; | ||
import { CoreDate } from "@nmshd/core-types"; | ||
import { AccountController, Transport } from "../../../src"; | ||
import { TestUtil } from "../../testHelpers/TestUtil"; | ||
|
||
describe("SyncController.ordered", function () { | ||
let connection: IDatabaseConnection; | ||
let transport: Transport; | ||
|
||
let sender: AccountController | undefined; | ||
let recipient: AccountController | undefined; | ||
let recipientSecondDevice: AccountController | undefined; | ||
|
||
beforeAll(async function () { | ||
connection = await TestUtil.createDatabaseConnection(); | ||
|
||
transport = TestUtil.createTransport(connection, { datawalletEnabled: true }); | ||
await transport.init(); | ||
|
||
sender = await TestUtil.createAccount(transport); | ||
recipient = await TestUtil.createAccount(transport); | ||
}); | ||
|
||
afterAll(async () => { | ||
await sender?.close(); | ||
await recipient?.close(); | ||
await recipientSecondDevice?.close(); | ||
|
||
await connection.close(); | ||
}); | ||
|
||
// eslint-disable-next-line jest/expect-expect -- no assertions are needed because it is sufficient that the onboarding does not throw an error | ||
test("onboarding does not throw an exception because datawallet modifications are executed in the correct order", async function () { | ||
const template = await sender!.relationshipTemplates.sendRelationshipTemplate({ content: {}, expiresAt: CoreDate.utc().add({ days: 1 }) }); | ||
|
||
// create and decompose a relationship | ||
await TestUtil.addRelationshipWithExistingTemplate(sender!, recipient!, template); | ||
await TestUtil.terminateAndDecomposeRelationshipMutually(sender!, recipient!); | ||
|
||
// create a relationship with the same template again | ||
await TestUtil.addRelationshipWithExistingTemplate(sender!, recipient!, template); | ||
|
||
// onboard a second device for the recipient | ||
const newDevice = await recipient!.devices.sendDevice({ name: "Test2", isAdmin: true }); | ||
await recipient!.syncDatawallet(); | ||
recipientSecondDevice = await TestUtil.onboardDevice(transport, await recipient!.devices.getSharedSecret(newDevice.id)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters