logs
This commit is contained in:
parent
375c5b4faa
commit
a844722013
4 changed files with 22 additions and 3 deletions
|
|
@ -125,7 +125,7 @@ export class StorageInterface extends EventEmitter {
|
|||
}
|
||||
|
||||
async Tx<T>(exec: TX<T>, description?: string): Promise<T> {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<T> = {
|
||||
type: 'endTx'
|
||||
txId: string
|
||||
opId: string
|
||||
debug?: boolean
|
||||
} & ({ success: true, data: T } | { success: false })
|
||||
|
||||
export type DeleteOperation<T> = {
|
||||
|
|
@ -37,6 +40,7 @@ export type DeleteOperation<T> = {
|
|||
opId: string
|
||||
q: number | FindOptionsWhere<T>
|
||||
txId?: string
|
||||
debug?: boolean
|
||||
}
|
||||
|
||||
export type RemoveOperation<T> = {
|
||||
|
|
@ -45,6 +49,7 @@ export type RemoveOperation<T> = {
|
|||
opId: string
|
||||
q: T
|
||||
txId?: string
|
||||
debug?: boolean
|
||||
}
|
||||
|
||||
export type UpdateOperation<T> = {
|
||||
|
|
@ -54,6 +59,7 @@ export type UpdateOperation<T> = {
|
|||
toUpdate: DeepPartial<T>
|
||||
q: number | FindOptionsWhere<T>
|
||||
txId?: string
|
||||
debug?: boolean
|
||||
}
|
||||
|
||||
export type IncrementOperation<T> = {
|
||||
|
|
@ -64,6 +70,7 @@ export type IncrementOperation<T> = {
|
|||
propertyPath: string,
|
||||
value: number | string
|
||||
txId?: string
|
||||
debug?: boolean
|
||||
}
|
||||
|
||||
export type DecrementOperation<T> = {
|
||||
|
|
@ -74,6 +81,7 @@ export type DecrementOperation<T> = {
|
|||
propertyPath: string,
|
||||
value: number | string
|
||||
txId?: string
|
||||
debug?: boolean
|
||||
}
|
||||
|
||||
export type FindOneOperation<T> = {
|
||||
|
|
@ -82,6 +90,7 @@ export type FindOneOperation<T> = {
|
|||
opId: string
|
||||
q: QueryOptions<T>
|
||||
txId?: string
|
||||
debug?: boolean
|
||||
}
|
||||
|
||||
export type FindOperation<T> = {
|
||||
|
|
@ -90,6 +99,7 @@ export type FindOperation<T> = {
|
|||
opId: string
|
||||
q: QueryOptions<T>
|
||||
txId?: string
|
||||
debug?: boolean
|
||||
}
|
||||
|
||||
export type SumOperation<T> = {
|
||||
|
|
@ -99,6 +109,7 @@ export type SumOperation<T> = {
|
|||
columnName: PickKeysByType<T, number>
|
||||
q: WhereCondition<T>
|
||||
txId?: string
|
||||
debug?: boolean
|
||||
}
|
||||
|
||||
export type CreateAndSaveOperation<T> = {
|
||||
|
|
@ -108,6 +119,7 @@ export type CreateAndSaveOperation<T> = {
|
|||
toSave: DeepPartial<T>
|
||||
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<T> = ConnectOperation | StartTxOperation | EndTxOperation<T> | DeleteOperation<T> | RemoveOperation<T> | UpdateOperation<T> |
|
||||
|
|
@ -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':
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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<any>, errorMessage?: string) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue