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> {
|
async Tx<T>(exec: TX<T>, description?: string): Promise<T> {
|
||||||
const txId = await this.StartTx()
|
const txId = await this.StartTx(description)
|
||||||
try {
|
try {
|
||||||
const res = await exec(txId)
|
const res = await exec(txId)
|
||||||
await this.EndTx(txId, true, res)
|
await this.EndTx(txId, true, res)
|
||||||
|
|
@ -162,6 +162,9 @@ export class StorageInterface extends EventEmitter {
|
||||||
if ('q' in serialized) {
|
if ('q' in serialized) {
|
||||||
(serialized as any).q = serializeRequest((serialized as any).q);
|
(serialized as any).q = serializeRequest((serialized as any).q);
|
||||||
}
|
}
|
||||||
|
if (this.debug) {
|
||||||
|
serialized.debug = true
|
||||||
|
}
|
||||||
return serialized;
|
return serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,18 +17,21 @@ export type ConnectOperation = {
|
||||||
type: 'connect'
|
type: 'connect'
|
||||||
opId: string
|
opId: string
|
||||||
settings: DbSettings
|
settings: DbSettings
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StartTxOperation = {
|
export type StartTxOperation = {
|
||||||
type: 'startTx'
|
type: 'startTx'
|
||||||
opId: string
|
opId: string
|
||||||
description?: string
|
description?: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EndTxOperation<T> = {
|
export type EndTxOperation<T> = {
|
||||||
type: 'endTx'
|
type: 'endTx'
|
||||||
txId: string
|
txId: string
|
||||||
opId: string
|
opId: string
|
||||||
|
debug?: boolean
|
||||||
} & ({ success: true, data: T } | { success: false })
|
} & ({ success: true, data: T } | { success: false })
|
||||||
|
|
||||||
export type DeleteOperation<T> = {
|
export type DeleteOperation<T> = {
|
||||||
|
|
@ -37,6 +40,7 @@ export type DeleteOperation<T> = {
|
||||||
opId: string
|
opId: string
|
||||||
q: number | FindOptionsWhere<T>
|
q: number | FindOptionsWhere<T>
|
||||||
txId?: string
|
txId?: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RemoveOperation<T> = {
|
export type RemoveOperation<T> = {
|
||||||
|
|
@ -45,6 +49,7 @@ export type RemoveOperation<T> = {
|
||||||
opId: string
|
opId: string
|
||||||
q: T
|
q: T
|
||||||
txId?: string
|
txId?: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateOperation<T> = {
|
export type UpdateOperation<T> = {
|
||||||
|
|
@ -54,6 +59,7 @@ export type UpdateOperation<T> = {
|
||||||
toUpdate: DeepPartial<T>
|
toUpdate: DeepPartial<T>
|
||||||
q: number | FindOptionsWhere<T>
|
q: number | FindOptionsWhere<T>
|
||||||
txId?: string
|
txId?: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IncrementOperation<T> = {
|
export type IncrementOperation<T> = {
|
||||||
|
|
@ -64,6 +70,7 @@ export type IncrementOperation<T> = {
|
||||||
propertyPath: string,
|
propertyPath: string,
|
||||||
value: number | string
|
value: number | string
|
||||||
txId?: string
|
txId?: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DecrementOperation<T> = {
|
export type DecrementOperation<T> = {
|
||||||
|
|
@ -74,6 +81,7 @@ export type DecrementOperation<T> = {
|
||||||
propertyPath: string,
|
propertyPath: string,
|
||||||
value: number | string
|
value: number | string
|
||||||
txId?: string
|
txId?: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FindOneOperation<T> = {
|
export type FindOneOperation<T> = {
|
||||||
|
|
@ -82,6 +90,7 @@ export type FindOneOperation<T> = {
|
||||||
opId: string
|
opId: string
|
||||||
q: QueryOptions<T>
|
q: QueryOptions<T>
|
||||||
txId?: string
|
txId?: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FindOperation<T> = {
|
export type FindOperation<T> = {
|
||||||
|
|
@ -90,6 +99,7 @@ export type FindOperation<T> = {
|
||||||
opId: string
|
opId: string
|
||||||
q: QueryOptions<T>
|
q: QueryOptions<T>
|
||||||
txId?: string
|
txId?: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SumOperation<T> = {
|
export type SumOperation<T> = {
|
||||||
|
|
@ -99,6 +109,7 @@ export type SumOperation<T> = {
|
||||||
columnName: PickKeysByType<T, number>
|
columnName: PickKeysByType<T, number>
|
||||||
q: WhereCondition<T>
|
q: WhereCondition<T>
|
||||||
txId?: string
|
txId?: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CreateAndSaveOperation<T> = {
|
export type CreateAndSaveOperation<T> = {
|
||||||
|
|
@ -108,6 +119,7 @@ export type CreateAndSaveOperation<T> = {
|
||||||
toSave: DeepPartial<T>
|
toSave: DeepPartial<T>
|
||||||
txId?: string
|
txId?: string
|
||||||
description?: string
|
description?: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ErrorOperationResponse = { success: false, error: string, opId: string }
|
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 {
|
export interface IStorageOperation {
|
||||||
opId: string
|
opId: string
|
||||||
type: string
|
type: string
|
||||||
|
debug?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StorageOperation<T> = ConnectOperation | StartTxOperation | EndTxOperation<T> | DeleteOperation<T> | RemoveOperation<T> | UpdateOperation<T> |
|
export type StorageOperation<T> = ConnectOperation | StartTxOperation | EndTxOperation<T> | DeleteOperation<T> | RemoveOperation<T> | UpdateOperation<T> |
|
||||||
|
|
@ -157,6 +170,9 @@ class StorageProcessor {
|
||||||
const opId = operation.opId;
|
const opId = operation.opId;
|
||||||
if ((operation as any).q) {
|
if ((operation as any).q) {
|
||||||
(operation as any).q = deserializeRequest((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) {
|
switch (operation.type) {
|
||||||
case 'connect':
|
case 'connect':
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,12 @@ import { Describe, expect, expectThrowsAsync, runSanityCheck, safelySetUserBalan
|
||||||
export const ignore = false
|
export const ignore = false
|
||||||
export const dev = false
|
export const dev = false
|
||||||
export default async (T: TestBase) => {
|
export default async (T: TestBase) => {
|
||||||
|
T.main.storage.dbs.setDebug(true)
|
||||||
await safelySetUserBalance(T, T.user1, 2000)
|
await safelySetUserBalance(T, T.user1, 2000)
|
||||||
await testSuccessfulExternalPayment(T)
|
await testSuccessfulExternalPayment(T)
|
||||||
await testFailedExternalPayment(T)
|
await testFailedExternalPayment(T)
|
||||||
await runSanityCheck(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) => {
|
export const runSanityCheck = async (T: TestBase) => {
|
||||||
T.main.storage.dbs.setDebug(true)
|
|
||||||
const sanityChecker = new SanityChecker(T.main.storage, T.main.lnd)
|
const sanityChecker = new SanityChecker(T.main.storage, T.main.lnd)
|
||||||
await sanityChecker.VerifyEventsLog()
|
await sanityChecker.VerifyEventsLog()
|
||||||
T.main.storage.dbs.setDebug(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const expectThrowsAsync = async (promise: Promise<any>, errorMessage?: string) => {
|
export const expectThrowsAsync = async (promise: Promise<any>, errorMessage?: string) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue