diff --git a/src/clients/mdw-ws-client.service.ts b/src/clients/mdw-ws-client.service.ts index c22b22f..efae778 100644 --- a/src/clients/mdw-ws-client.service.ts +++ b/src/clients/mdw-ws-client.service.ts @@ -66,7 +66,7 @@ export class MdwWsClientService { return ws; }; - createMessageHandler = + private createMessageHandler = (callbacks: Callbacks, ws: WebSocket, logger: Logger) => async (msg: WebSocket.RawData) => { const stringMessage = msg.toString(); diff --git a/src/tasks/pair-sync.service.ts b/src/tasks/pair-sync.service.ts index fe54773..0336962 100644 --- a/src/tasks/pair-sync.service.ts +++ b/src/tasks/pair-sync.service.ts @@ -51,12 +51,12 @@ export class PairSyncService implements OnModuleInit { }); }; - unsyncAllPairs = async () => { + private unsyncAllPairs = async () => { const batch = await this.pairDbService.unsyncAllPairs(); this.logger.log(`${batch.count} pairs marked as unsync`); }; - refreshPairs = async (ctx: Context): Promise => { + private refreshPairs = async (ctx: Context): Promise => { this.logger.log(`Getting all pairs from Factory...`); const { decodedResult: allFactoryPairs } = await ctx.factory.get_all_pairs(); @@ -111,7 +111,7 @@ export class PairSyncService implements OnModuleInit { return newAddresses.concat(futurePairs); }; - refreshPairsLiquidity = async (ctx: Context) => { + private refreshPairsLiquidity = async (ctx: Context) => { //get the all pairs const dbPairs = await this.pairDbService.getAllWithCondition(true); this.logger.log(`Refreshing pairs liquidity...`); @@ -121,7 +121,7 @@ export class PairSyncService implements OnModuleInit { this.logger.log(`Pairs liquidity refresh completed`); }; - createOnEventReceived = + private createOnEventReceived = ( ctx: Context, logger: Logger, diff --git a/test/mdw-ws-client.service.spec.ts b/test/mdw-ws-client.service.spec.ts index bed0aa4..080e613 100644 --- a/test/mdw-ws-client.service.spec.ts +++ b/test/mdw-ws-client.service.spec.ts @@ -46,7 +46,7 @@ describe('MdwWsClientService', () => { const callbacks = mock(); const ws = mock(); const logger = mock(); - const msgHandler = service.createMessageHandler(callbacks, ws, logger); + const msgHandler = service['createMessageHandler'](callbacks, ws, logger); return { callbacks, ws, logger, msgHandler }; }; diff --git a/test/pair-sync.service.e2e-spec.ts b/test/pair-sync.service.e2e-spec.ts index 3a20eb8..558e6e0 100644 --- a/test/pair-sync.service.e2e-spec.ts +++ b/test/pair-sync.service.e2e-spec.ts @@ -36,7 +36,7 @@ describe('PairSyncService', () => { beforeEach(async () => { await cleanDb(prismaService); const ctx = mockContext(data.context2); - await service.refreshPairs(ctx); + await service['refreshPairs'](ctx); }); afterAll(async () => { @@ -56,7 +56,7 @@ describe('PairSyncService', () => { it('refresh pairs liquidity', async () => { const ctx = mockContext(data.context2); - await service.refreshPairsLiquidity(ctx); + await service['refreshPairsLiquidity'](ctx); const pairs = await prismaService.pair.findMany({ include: { liquidityInfo: true }, @@ -74,7 +74,7 @@ describe('PairSyncService', () => { it('refresh new added pairs', async () => { const ctx = mockContext(data.context21); - await service.refreshPairs(ctx); + await service['refreshPairs'](ctx); const pairs: prisma.Pair[] = await prismaService.pair.findMany({ orderBy: { id: 'asc' }, }); @@ -87,8 +87,8 @@ describe('PairSyncService', () => { it('refresh liquidity for new added pairs', async () => { const ctx = mockContext(data.context21); - await service.refreshPairs(ctx); - await service.refreshPairsLiquidity(ctx); + await service['refreshPairs'](ctx); + await service['refreshPairsLiquidity'](ctx); const pairs = await prismaService.pair.findMany({ include: { liquidityInfo: true }, orderBy: { address: 'asc' }, @@ -102,7 +102,7 @@ describe('PairSyncService', () => { }); it('unsync all pairs', async () => { - await service.unsyncAllPairs(); + await service['unsyncAllPairs'](); const pairs = await prismaService.pair.findMany({ where: { synchronized: true }, }); diff --git a/test/pair-sync.service.spec.ts b/test/pair-sync.service.spec.ts index db98369..b36f856 100644 --- a/test/pair-sync.service.spec.ts +++ b/test/pair-sync.service.spec.ts @@ -25,7 +25,7 @@ const initTestContext = (service: PairSyncService) => { }; const { onFactory, refreshPairsLiquidity, getAllAddresses } = mock(); const logger = mock(); - const eventHandler = service.createOnEventReceived( + const eventHandler = service['createOnEventReceived']( ctx, logger, onFactory, diff --git a/test/pairs.e2e-spec.ts b/test/pairs.e2e-spec.ts index 06ec885..f591b74 100644 --- a/test/pairs.e2e-spec.ts +++ b/test/pairs.e2e-spec.ts @@ -55,7 +55,7 @@ describe('PairsController', () => { beforeEach(async () => { await cleanDb(prismaService); const ctx = mockContext(data.context2); - await pairSyncService.refreshPairs(ctx); + await pairSyncService['refreshPairs'](ctx); }); describe('/pairs', () => { @@ -87,7 +87,7 @@ describe('PairsController', () => { it('/pairs (GET) 200 synchronized', async () => { const ctx1 = mockContext(data.context2); - await pairSyncService.refreshPairsLiquidity(ctx1); + await pairSyncService['refreshPairsLiquidity'](ctx1); const response = await request(app.getHttpServer()) .get('/pairs') .expect(200); @@ -116,9 +116,9 @@ describe('PairsController', () => { it('/pairs (GET) 200 with new pair', async () => { const ctx1 = mockContext(data.context2); - await pairSyncService.refreshPairsLiquidity(ctx1); + await pairSyncService['refreshPairsLiquidity'](ctx1); const ctx2 = mockContext(data.context21); - await pairSyncService.refreshPairs(ctx2); + await pairSyncService['refreshPairs'](ctx2); const response = await request(app.getHttpServer()) .get('/pairs') .expect(200); @@ -153,9 +153,9 @@ describe('PairsController', () => { it('/pairs (GET) 200 only-listed=true', async () => { const ctx1 = mockContext(data.context2); - await pairSyncService.refreshPairsLiquidity(ctx1); + await pairSyncService['refreshPairsLiquidity'](ctx1); const ctx2 = mockContext(data.context21); - await pairSyncService.refreshPairs(ctx2); + await pairSyncService['refreshPairs'](ctx2); let response = await request(app.getHttpServer()) .get('/pairs?only-listed=true') @@ -215,7 +215,7 @@ describe('PairsController', () => { it('/pairs/by-address/ct_p1 (GET) 200 synchronized', async () => { const ctx1 = mockContext(data.context2); - await pairSyncService.refreshPairsLiquidity(ctx1); + await pairSyncService['refreshPairsLiquidity'](ctx1); return request(app.getHttpServer()) .get('/pairs/by-address/ct_p1') .expect(200) @@ -251,8 +251,8 @@ describe('PairsController', () => { it('/pairs/by-address/ct_p1 (GET) 200 unsynchronized with liquidity', async () => { const ctx1 = mockContext(data.context2); - await pairSyncService.refreshPairsLiquidity(ctx1); - await pairSyncService.unsyncAllPairs(); + await pairSyncService['refreshPairsLiquidity'](ctx1); + await pairSyncService['unsyncAllPairs'](); return request(app.getHttpServer()) .get('/pairs/by-address/ct_p1') .expect(200) @@ -318,7 +318,7 @@ describe('PairsController', () => { }, }), }); - await pairSyncService.refreshPairs(ctx); + await pairSyncService['refreshPairs'](ctx); return request(app.getHttpServer()) .get('/pairs/swap-routes/ct_t0/ct_t5') @@ -328,7 +328,7 @@ describe('PairsController', () => { it('/pairs/swap-routes/ct_t0/ct_t4 (GET) 200 direct path', async () => { const ctx = mockContext(data.context21); - await pairSyncService.refreshPairs(ctx); + await pairSyncService['refreshPairs'](ctx); return request(app.getHttpServer()) .get('/pairs/swap-routes/ct_t0/ct_t4') @@ -347,7 +347,7 @@ describe('PairsController', () => { it('/pairs/swap-routes/ct_t0/ct_t3 (GET) 200 synchronized', async () => { const ctx = mockContext(data.context21); - await pairSyncService.refreshPairsLiquidity(ctx); + await pairSyncService['refreshPairsLiquidity'](ctx); return request(app.getHttpServer()) .get('/pairs/swap-routes/ct_t0/ct_t1') @@ -486,7 +486,7 @@ describe('PairsController', () => { t1: 3, }), }); - await pairSyncService.refreshPairs(ctx); + await pairSyncService['refreshPairs'](ctx); return request(app.getHttpServer()) .get('/pairs/swap-routes/ct_t0/ct_t1') diff --git a/test/tokens.e2e-spec.ts b/test/tokens.e2e-spec.ts index ac5762f..c65cfab 100644 --- a/test/tokens.e2e-spec.ts +++ b/test/tokens.e2e-spec.ts @@ -54,7 +54,7 @@ describe('TokenController', () => { beforeEach(async () => { await cleanDb(prismaService); const ctx = mockContext(data.context2); - await pairSyncService.refreshPairs(ctx); + await pairSyncService['refreshPairs'](ctx); }); afterAll(async () => { @@ -244,8 +244,8 @@ describe('TokenController', () => { it('/tokens/by-address/ct_t0/pairs (GET) 200 with pairs only on pairs0', async () => { const ctx = utils.mockContext(data.context21); - await pairSyncService.refreshPairs(ctx); - await pairSyncService.refreshPairsLiquidity(ctx); + await pairSyncService['refreshPairs'](ctx); + await pairSyncService['refreshPairsLiquidity'](ctx); const response = await request(app.getHttpServer()) .get('/tokens/by-address/ct_t0/pairs') @@ -317,8 +317,8 @@ describe('TokenController', () => { it('/tokens/by-address/ct_t3/pairs (GET) 200 with pairs only on pairs1', async () => { const ctx = utils.mockContext(data.context21); - await pairSyncService.refreshPairs(ctx); - await pairSyncService.refreshPairsLiquidity(ctx); + await pairSyncService['refreshPairs'](ctx); + await pairSyncService['refreshPairsLiquidity'](ctx); await utils.listToken(prismaService, 'ct_t0'); await utils.listToken(prismaService, 'ct_t3'); @@ -393,8 +393,8 @@ describe('TokenController', () => { }, ]), }); - await pairSyncService.refreshPairs(ctx); - await pairSyncService.refreshPairsLiquidity(ctx); + await pairSyncService['refreshPairs'](ctx); + await pairSyncService['refreshPairsLiquidity'](ctx); await utils.listToken(prismaService, 'ct_t0'); await utils.listToken(prismaService, 'ct_t3');