diff --git a/src/services/storage/storageInterface.ts b/src/services/storage/storageInterface.ts index 7583a1a3..ca0cfdfd 100644 --- a/src/services/storage/storageInterface.ts +++ b/src/services/storage/storageInterface.ts @@ -125,7 +125,7 @@ export class StorageInterface extends EventEmitter { } async Tx(exec: TX, description?: string): Promise { - const txId = await this.StartTx() + const txId = await this.StartTx(description) try { const res = await exec(txId) await this.EndTx(txId, true, res) @@ -162,6 +162,9 @@ export class StorageInterface extends EventEmitter { if ('q' in serialized) { (serialized as any).q = serializeRequest((serialized as any).q); } + if (this.debug) { + serialized.debug = true + } return serialized; } diff --git a/src/services/storage/storageProcessor.ts b/src/services/storage/storageProcessor.ts index 2b73fe9e..e20252d1 100644 --- a/src/services/storage/storageProcessor.ts +++ b/src/services/storage/storageProcessor.ts @@ -17,18 +17,21 @@ export type ConnectOperation = { type: 'connect' opId: string settings: DbSettings + debug?: boolean } export type StartTxOperation = { type: 'startTx' opId: string description?: string + debug?: boolean } export type EndTxOperation = { type: 'endTx' txId: string opId: string + debug?: boolean } & ({ success: true, data: T } | { success: false }) export type DeleteOperation = { @@ -37,6 +40,7 @@ export type DeleteOperation = { opId: string q: number | FindOptionsWhere txId?: string + debug?: boolean } export type RemoveOperation = { @@ -45,6 +49,7 @@ export type RemoveOperation = { opId: string q: T txId?: string + debug?: boolean } export type UpdateOperation = { @@ -54,6 +59,7 @@ export type UpdateOperation = { toUpdate: DeepPartial q: number | FindOptionsWhere txId?: string + debug?: boolean } export type IncrementOperation = { @@ -64,6 +70,7 @@ export type IncrementOperation = { propertyPath: string, value: number | string txId?: string + debug?: boolean } export type DecrementOperation = { @@ -74,6 +81,7 @@ export type DecrementOperation = { propertyPath: string, value: number | string txId?: string + debug?: boolean } export type FindOneOperation = { @@ -82,6 +90,7 @@ export type FindOneOperation = { opId: string q: QueryOptions txId?: string + debug?: boolean } export type FindOperation = { @@ -90,6 +99,7 @@ export type FindOperation = { opId: string q: QueryOptions txId?: string + debug?: boolean } export type SumOperation = { @@ -99,6 +109,7 @@ export type SumOperation = { columnName: PickKeysByType q: WhereCondition txId?: string + debug?: boolean } export type CreateAndSaveOperation = { @@ -108,6 +119,7 @@ export type CreateAndSaveOperation = { toSave: DeepPartial txId?: string description?: string + debug?: boolean } export type ErrorOperationResponse = { success: false, error: string, opId: string } @@ -115,6 +127,7 @@ export type ErrorOperationResponse = { success: false, error: string, opId: stri export interface IStorageOperation { opId: string type: string + debug?: boolean } export type StorageOperation = ConnectOperation | StartTxOperation | EndTxOperation | DeleteOperation | RemoveOperation | UpdateOperation | @@ -157,6 +170,9 @@ class StorageProcessor { const opId = operation.opId; if ((operation as any).q) { (operation as any).q = deserializeRequest((operation as any).q) + if (operation.debug) { + this.log(operation.type, opId, (operation as any).q) + } } switch (operation.type) { case 'connect': diff --git a/src/tests/externalPayment.spec.ts b/src/tests/externalPayment.spec.ts index f5524ed1..80267e76 100644 --- a/src/tests/externalPayment.spec.ts +++ b/src/tests/externalPayment.spec.ts @@ -3,10 +3,12 @@ import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalan export const ignore = false export const dev = false export default async (T: TestBase) => { + T.main.storage.dbs.setDebug(true) await safelySetUserBalance(T, T.user1, 2000) await testSuccessfulExternalPayment(T) await testFailedExternalPayment(T) await runSanityCheck(T) + T.main.storage.dbs.setDebug(false) } diff --git a/src/tests/testBase.ts b/src/tests/testBase.ts index b2a6e320..a3b716b7 100644 --- a/src/tests/testBase.ts +++ b/src/tests/testBase.ts @@ -111,10 +111,8 @@ export const safelySetUserBalance = async (T: TestBase, user: TestUserData, amou } export const runSanityCheck = async (T: TestBase) => { - T.main.storage.dbs.setDebug(true) const sanityChecker = new SanityChecker(T.main.storage, T.main.lnd) await sanityChecker.VerifyEventsLog() - T.main.storage.dbs.setDebug(false) } export const expectThrowsAsync = async (promise: Promise, errorMessage?: string) => {