diff --git a/packages/cactus-plugin-satp-hermes/package.json b/packages/cactus-plugin-satp-hermes/package.json index 6179abe0b8..8585599e13 100644 --- a/packages/cactus-plugin-satp-hermes/package.json +++ b/packages/cactus-plugin-satp-hermes/package.json @@ -45,7 +45,7 @@ "scripts": { "build": "run-p tsc codegen", "build-proto": "buf build --path src/main/proto --verbose", - "build:dev:backend:postbuild": "mkdir -p ./dist/lib/main/knex && cp -r ./knex/* ./dist/lib/main/knex", + "build:dev:backend:postbuild": "mkdir -p ./dist/lib/knex && cp -r ./src/knex/* ./dist/lib/knex", "codegen": "run-p 'codegen:*'", "codegen:openapi": "npm run generate-sdk", "codegen:proto": "npm run generate-proto", diff --git a/packages/cactus-plugin-satp-hermes/knex/knexfile-remote.ts b/packages/cactus-plugin-satp-hermes/src/knex/knexfile-remote.ts similarity index 78% rename from packages/cactus-plugin-satp-hermes/knex/knexfile-remote.ts rename to packages/cactus-plugin-satp-hermes/src/knex/knexfile-remote.ts index 27e1209742..aec68f17c7 100644 --- a/packages/cactus-plugin-satp-hermes/knex/knexfile-remote.ts +++ b/packages/cactus-plugin-satp-hermes/src/knex/knexfile-remote.ts @@ -6,7 +6,7 @@ module.exports = { development: { client: "sqlite3", connection: { - filename: path.resolve(__dirname, ".dev-remote.sqlite3"), + filename: path.resolve(__dirname, ".dev.remote-" + uuidv4() + ".sqlite3"), }, migrations: { directory: path.resolve(__dirname, "migrations"), diff --git a/packages/cactus-plugin-satp-hermes/knex/knexfile.ts b/packages/cactus-plugin-satp-hermes/src/knex/knexfile.ts similarity index 100% rename from packages/cactus-plugin-satp-hermes/knex/knexfile.ts rename to packages/cactus-plugin-satp-hermes/src/knex/knexfile.ts diff --git a/packages/cactus-plugin-satp-hermes/knex/migrations/20220331132128_create_logs_table.js b/packages/cactus-plugin-satp-hermes/src/knex/migrations/20220331132128_create_logs_table.js similarity index 100% rename from packages/cactus-plugin-satp-hermes/knex/migrations/20220331132128_create_logs_table.js rename to packages/cactus-plugin-satp-hermes/src/knex/migrations/20220331132128_create_logs_table.js diff --git a/packages/cactus-plugin-satp-hermes/knex/migrations/20240130234303_create_remote_logs_table.js b/packages/cactus-plugin-satp-hermes/src/knex/migrations/20240130234303_create_remote_logs_table.js similarity index 100% rename from packages/cactus-plugin-satp-hermes/knex/migrations/20240130234303_create_remote_logs_table.js rename to packages/cactus-plugin-satp-hermes/src/knex/migrations/20240130234303_create_remote_logs_table.js diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/repository/knex-local-log-repository.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/repository/knex-local-log-repository.ts index b977e3e111..65c07b10de 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/repository/knex-local-log-repository.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/repository/knex-local-log-repository.ts @@ -7,7 +7,7 @@ export class KnexLocalLogRepository implements ILocalLogRepository { public constructor(config: Knex.Config | undefined) { // eslint-disable-next-line @typescript-eslint/no-var-requires - const configFile = require("../../../../knex/knexfile.ts")[ + const configFile = require("../../../knex/knexfile.ts")[ process.env.ENVIRONMENT || "development" ]; diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/repository/knex-remote-log-repository.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/repository/knex-remote-log-repository.ts index 9431076d0a..8d064da275 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/repository/knex-remote-log-repository.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/repository/knex-remote-log-repository.ts @@ -10,7 +10,7 @@ export class KnexRemoteLogRepository implements IRemoteLogRepository { // simulating a remote log storage public constructor(config: Knex.Config | undefined) { // eslint-disable-next-line @typescript-eslint/no-var-requires - const configFile = require("../../../../knex/knexfile-remote.ts")[ + const configFile = require("../../../knex/knexfile-remote.ts")[ process.env.ENVIRONMENT || "development" ]; diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/backup-gateway-after-client-crash.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/backup-gateway-after-client-crash.test.ts index b51eb5dd6d..1d7f1259c2 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/backup-gateway-after-client-crash.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/backup-gateway-after-client-crash.test.ts @@ -547,12 +547,16 @@ beforeAll(async () => { pluginRecipientGateway = new BesuSATPGateway(serverGatewayPluginOptions); expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); - expect( - pluginRecipientGateway.localRepository?.database, - ).not.toBeUndefined(); - + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); + await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); } { // Server Gateway configuration diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-delete-asset.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-delete-asset.test.ts index 86c5984540..0097ad54b8 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-delete-asset.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-delete-asset.test.ts @@ -544,12 +544,16 @@ beforeAll(async () => { pluginRecipientGateway = new BesuSATPGateway(serverGatewayPluginOptions); expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); - expect( - pluginRecipientGateway.localRepository?.database, - ).not.toBeUndefined(); - + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); + await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); } { // Server Gateway configuration diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-lock-asset.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-lock-asset.test.ts index d8dae07561..1c0609221f 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-lock-asset.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-lock-asset.test.ts @@ -545,12 +545,16 @@ beforeAll(async () => { pluginRecipientGateway = new BesuSATPGateway(serverGatewayPluginOptions); expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); - expect( - pluginRecipientGateway.localRepository?.database, - ).not.toBeUndefined(); - + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); + await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); } { // Server Gateway configuration diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-transfer-initiation.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-transfer-initiation.test.ts index 60a3521d69..c36d1ef54a 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-transfer-initiation.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/client-crash-after-transfer-initiation.test.ts @@ -88,11 +88,11 @@ beforeAll(async () => { pluginRecipientGateway = new BesuSATPGateway(serverGatewayPluginOptions); - expect( - pluginRecipientGateway.localRepository?.database, - ).not.toBeUndefined(); - + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); + await pluginRecipientGateway.localRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); await pluginRecipientGateway.registerWebServices(serverExpressApp); } diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-api-call-with-ledger-connector.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-api-call-with-ledger-connector.test.ts index 51ce622134..e080b4d2b4 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-api-call-with-ledger-connector.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-api-call-with-ledger-connector.test.ts @@ -507,12 +507,16 @@ beforeAll(async () => { pluginRecipientGateway = new BesuSATPGateway(serverGatewayPluginOptions); expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); - expect( - pluginRecipientGateway.localRepository?.database, - ).not.toBeUndefined(); - + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); + await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); } { // Server Gateway configuration diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-api-call.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-api-call.test.ts index 2f5ec22b1c..2ca64db806 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-api-call.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-api-call.test.ts @@ -62,9 +62,15 @@ test("runs ODAP between two gateways via openApi", async () => { expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); let serverGatewayApiHost: string; diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-rollback.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-rollback.test.ts index af92b02d7d..c78f6281a2 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-rollback.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap-rollback.test.ts @@ -546,8 +546,14 @@ beforeAll(async () => { pluginRecipientGateway.localRepository?.database, ).not.toBeUndefined(); + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); + await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); } { // Server Gateway configuration diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap.test.ts index 7b5eef9118..213de32742 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/odap.test.ts @@ -44,9 +44,15 @@ test("successful run ODAP instance", async () => { expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); const dummyPath = { apiHost: "dummyPath" }; diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/server-crash-after-create-asset.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/server-crash-after-create-asset.test.ts index c0d496f64e..8faad3f042 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/server-crash-after-create-asset.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/server-crash-after-create-asset.test.ts @@ -547,12 +547,16 @@ beforeEach(async () => { pluginRecipientGateway = new BesuSATPGateway(serverGatewayPluginOptions); expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); - expect( - pluginRecipientGateway.localRepository?.database, - ).not.toBeUndefined(); - + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); + await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); } { // Server Gateway configuration diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/server-crash-after-transfer-initiation.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/server-crash-after-transfer-initiation.test.ts index 92f0f6296a..805ef8da07 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/server-crash-after-transfer-initiation.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/integration/server-crash-after-transfer-initiation.test.ts @@ -84,11 +84,11 @@ beforeAll(async () => { pluginRecipientGateway = new BesuSATPGateway(serverGatewayPluginOptions); - expect( - pluginRecipientGateway.localRepository?.database, - ).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginRecipientGateway.localRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); await pluginRecipientGateway.registerWebServices(serverExpressApp); } @@ -123,11 +123,11 @@ beforeAll(async () => { pluginSourceGateway = new FabricSATPGateway(clientGatewayPluginOptions); - if (pluginSourceGateway.localRepository?.database == undefined) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); + await pluginSourceGateway.remoteRepository?.reset(); await pluginSourceGateway.registerWebServices(clientExpressApp); @@ -218,10 +218,10 @@ test("server gateway crashes after transfer initiation flow", async () => { }); afterAll(async () => { - pluginSourceGateway.localRepository?.destroy(); - pluginRecipientGateway.localRepository?.destroy(); - pluginSourceGateway.remoteRepository?.destroy(); - pluginRecipientGateway.remoteRepository?.destroy(); + await pluginSourceGateway.localRepository?.destroy(); + await pluginRecipientGateway.localRepository?.destroy(); + await pluginSourceGateway.remoteRepository?.destroy(); + await pluginRecipientGateway.remoteRepository?.destroy(); await Servers.shutdown(sourceGatewayServer); await Servers.shutdown(recipientGatewayserver); diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/knex.config.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/knex.config.ts index 3376a92c91..c533074692 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/knex.config.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/knex.config.ts @@ -1,10 +1,12 @@ +import { v4 as uuidv4 } from "uuid"; + export const knexClientConnection = { client: "sqlite3", connection: { - filename: "./packages/cactus-plugin-satp-hermes/knex/.dev.client.sqlite3", + filename: "./packages/cactus-plugin-satp-hermes/src/knex/.dev.client-" + uuidv4() + ".sqlite3", }, migrations: { - directory: "./packages/cactus-plugin-satp-hermes/knex/migrations", + directory: "./packages/cactus-plugin-satp-hermes/src/knex/migrations", }, useNullAsDefault: true, }; @@ -12,10 +14,10 @@ export const knexClientConnection = { export const knexServerConnection = { client: "sqlite3", connection: { - filename: "./packages/cactus-plugin-satp-hermes/knex/.dev.server.sqlite3", + filename: "./packages/cactus-plugin-satp-hermes/src/knex/.dev.server-" + uuidv4() + ".sqlite3", }, migrations: { - directory: "./packages/cactus-plugin-satp-hermes/knex/migrations", + directory: "./packages/cactus-plugin-satp-hermes/src/knex/migrations", }, useNullAsDefault: true, }; @@ -23,10 +25,10 @@ export const knexServerConnection = { export const knexRemoteConnection = { client: "sqlite3", connection: { - filename: "./packages/cactus-plugin-satp-hermes/knex/.dev.remote.sqlite3", + filename: "./packages/cactus-plugin-satp-hermes/src/knex/.dev.remote-" + uuidv4() + ".sqlite3", }, migrations: { - directory: "./packages/cactus-plugin-satp-hermes/knex/migrations", + directory: "./packages/cactus-plugin-satp-hermes/src/knex/migrations", }, useNullAsDefault: true, }; diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/commit-final.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/commit-final.test.ts index af553bf07f..9a5c2a23b7 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/commit-final.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/commit-final.test.ts @@ -51,15 +51,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); sequenceNumber = randomInt(100); sessionID = uuidv4(); @@ -88,16 +90,6 @@ beforeEach(async () => { operation: "create", data: COMMIT_ACK_CLAIM, }); - - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } - - await pluginSourceGateway.localRepository?.reset(); - await pluginRecipientGateway.localRepository?.reset(); }); afterEach(async () => { diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/commit-preparation.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/commit-preparation.test.ts index 03494513f3..737549ed05 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/commit-preparation.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/commit-preparation.test.ts @@ -48,15 +48,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); sequenceNumber = randomInt(100); sessionID = uuidV4(); diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/lock-evidence.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/lock-evidence.test.ts index eec07d8763..ac3aa68730 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/lock-evidence.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/lock-evidence.test.ts @@ -47,15 +47,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); sequenceNumber = randomInt(100); sessionID = uuidV4(); diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/transfer-commence.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/transfer-commence.test.ts index 9a098ad4fa..81da65aef6 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/transfer-commence.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/transfer-commence.test.ts @@ -47,15 +47,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); sequenceNumber = randomInt(100); sessionID = uuidV4(); diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/transfer-initialization.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/transfer-initialization.test.ts index 434e74777d..ca998bc95d 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/transfer-initialization.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/client/transfer-initialization.test.ts @@ -48,15 +48,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); sequenceNumber = randomInt(100); sessionID = uuidV4(); diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/logging.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/logging.test.ts index 5087233c80..a867986cee 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/logging.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/logging.test.ts @@ -86,15 +86,19 @@ beforeEach(async () => { pluginSourceGateway.sessions.set(sessionID, sessionData); pluginRecipientGateway.sessions.set(sessionID, sessionData); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); }); test("successful translation of log keys", async () => { diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-success.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-success.test.ts index f788ac6571..a3e80345d0 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-success.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-success.test.ts @@ -57,8 +57,17 @@ beforeEach(async () => { throw new Error("Database is not correctly initialized"); } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); + await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); sessionID = uuidv4(); sequenceNumber = randomInt(100); diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-update-ack.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-update-ack.test.ts index d322274466..83154dcc84 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-update-ack.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-update-ack.test.ts @@ -50,15 +50,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); sessionID = uuidv4(); sequenceNumber = randomInt(100); diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-update.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-update.test.ts index 1f3ad2cc77..f56b917a08 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-update.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover-update.test.ts @@ -62,15 +62,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); sessionID = uuidv4(); sequenceNumber = randomInt(100); @@ -185,7 +187,6 @@ test("check valid build of recover update message", async () => { throw new Error("Test Failed"); } - console.log(recoverUpdateMessage.recoveredLogs); expect(recoverUpdateMessage.recoveredLogs.length).toBe(3); await checkValidRecoverUpdateMessage( diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover.test.ts index ad76becf89..f516efd817 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/recovery/recover.test.ts @@ -68,15 +68,17 @@ beforeEach(async () => { pluginSourceGateway.sessions.set(sessionID, sessionData); pluginRecipientGateway.sessions.set(sessionID, sessionData); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); }); test("valid recover message request from client", async () => { diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/commit-final.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/commit-final.test.ts index 68b49e8c2f..fff1bf0a3a 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/commit-final.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/commit-final.test.ts @@ -52,15 +52,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); dummyCommitPreparationResponseMessageHash = SHA256( "commitPreparationResponseMessageData", @@ -93,16 +95,6 @@ beforeEach(async () => { operation: "delete", data: COMMIT_FINAL_CLAIM, } as ILocalLog); - - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } - - await pluginSourceGateway.localRepository?.reset(); - await pluginRecipientGateway.localRepository?.reset(); }); test("valid commit final request", async () => { diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/commit-preparation.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/commit-preparation.test.ts index dfc48380da..127ce29f9c 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/commit-preparation.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/commit-preparation.test.ts @@ -43,15 +43,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); dummyLockEvidenceResponseMessageHash = SHA256( "lockEvidenceResponseMessageData", diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/lock-evidence.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/lock-evidence.test.ts index 093e73971e..6c0552d18c 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/lock-evidence.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/lock-evidence.test.ts @@ -50,16 +50,18 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); - + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); + dummyTransferCommenceResponseMessageHash = SHA256( "transferCommenceResponseMessageData", ).toString(); @@ -94,21 +96,6 @@ beforeEach(async () => { operation: "lock", data: LOCK_EVIDENCE_CLAIM, }); - - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } - - await pluginSourceGateway.localRepository?.reset(); - await pluginRecipientGateway.localRepository?.reset(); -}); - -afterEach(() => { - pluginSourceGateway.localRepository?.destroy(); - pluginRecipientGateway.localRepository?.destroy(); }); test("valid lock evidence request", async () => { diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-commence.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-commence.test.ts index 59bbe0e80b..e23bd5b7a9 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-commence.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-commence.test.ts @@ -47,15 +47,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); dummyInitializationResponseMessageHash = SHA256( "initializationResponseMessageData", diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-complete.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-complete.test.ts index dbd97be6d9..a2ad3a7cc1 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-complete.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-complete.test.ts @@ -44,15 +44,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); dummyCommitFinalResponseMessageHash = SHA256( "commitFinalResponseMessageData", diff --git a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-initialization.test.ts b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-initialization.test.ts index c32508dcd9..b8d3d5a26b 100644 --- a/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-initialization.test.ts +++ b/packages/cactus-plugin-satp-hermes/src/test/typescript/unit/server/transfer-initialization.test.ts @@ -44,15 +44,17 @@ beforeEach(async () => { pluginSourceGateway = new FabricSATPGateway(sourceGatewayConstructor); pluginRecipientGateway = new BesuSATPGateway(recipientGatewayConstructor); - if ( - pluginSourceGateway.localRepository?.database == undefined || - pluginRecipientGateway.localRepository?.database == undefined - ) { - throw new Error("Database is not correctly initialized"); - } + expect(pluginSourceGateway.localRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.localRepository?.database).not.toBeUndefined(); + + expect(pluginSourceGateway.remoteRepository?.database).not.toBeUndefined(); + expect(pluginRecipientGateway.remoteRepository?.database).not.toBeUndefined(); await pluginSourceGateway.localRepository?.reset(); await pluginRecipientGateway.localRepository?.reset(); + + await pluginSourceGateway.remoteRepository?.reset(); + await pluginRecipientGateway.remoteRepository?.reset(); expiryDate = new Date(2060, 11, 24).toString(); assetProfile = { expirationDate: expiryDate };