diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0aa135b..eb4f41b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,9 +6,7 @@ on: - main tags: - 'v*' - pull_request: - branches: [ main ] - types: [ opened ] + pull_request: {} jobs: main: @@ -31,11 +29,11 @@ jobs: --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 100 - - uses: actions/cache@v2 + - uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} @@ -43,9 +41,6 @@ jobs: - name: npm install run: npm ci - - name: npm lint - run: npm run lint - - name: unit test run: npm run test diff --git a/prisma/migrations/20240313142140_add_pair_liquidity_info_history/migration.sql b/prisma/migrations/20240313142140_add_pair_liquidity_info_history/migration.sql index 1ed26c4..ce0f40f 100644 --- a/prisma/migrations/20240313142140_add_pair_liquidity_info_history/migration.sql +++ b/prisma/migrations/20240313142140_add_pair_liquidity_info_history/migration.sql @@ -33,7 +33,7 @@ CREATE UNIQUE INDEX "PairLiquidityInfoHistory_pairId_microBlockHash_key" ON "Pai CREATE UNIQUE INDEX "PairLiquidityInfoHistoryError_pairId_microBlockHash_error_key" ON "PairLiquidityInfoHistoryError"("pairId", "microBlockHash", "error"); -- AddForeignKey -ALTER TABLE "PairLiquidityInfoHistory" ADD CONSTRAINT "PairLiquidityInfoHistory_pairId_fkey" FOREIGN KEY ("pairId") REFERENCES "Pair"("id") ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE "PairLiquidityInfoHistory" ADD CONSTRAINT "PairLiquidityInfoHistory_pairId_fkey" FOREIGN KEY ("pairId") REFERENCES "Pair"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "PairLiquidityInfoHistoryError" ADD CONSTRAINT "PairLiquidityInfoHistoryError_pairId_fkey" FOREIGN KEY ("pairId") REFERENCES "Pair"("id") ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE "PairLiquidityInfoHistoryError" ADD CONSTRAINT "PairLiquidityInfoHistoryError_pairId_fkey" FOREIGN KEY ("pairId") REFERENCES "Pair"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c3ddf23..87acb9d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -63,7 +63,7 @@ model PairLiquidityInfoHistory { model PairLiquidityInfoHistoryError { id Int @id @default(autoincrement()) - pair Pair @relation(fields: [pairId], references: [id]) + pair Pair @relation(fields: [pairId], references: [id], onDelete: Cascade) pairId Int microBlockHash String error String diff --git a/test/pairs.e2e-spec.ts b/test/pairs.e2e-spec.ts index f195fa3..6606f7e 100644 --- a/test/pairs.e2e-spec.ts +++ b/test/pairs.e2e-spec.ts @@ -1,11 +1,12 @@ import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; import * as request from 'supertest'; -import { AppModule } from '../src/app.module'; -import { mockContext, listToken, sortByAddress } from './utils'; +import { listToken, mockContext, sortByAddress } from './utils'; import createWorkerMethods from '../src/worker'; import * as data from './data/context-mockups'; import * as db from './utils/db'; +import { TokensModule } from '../src/api/tokens/module'; +import { PairsModule } from '../src/api/pairs/module'; type WorkerMethods = ReturnType; let activeWorker: WorkerMethods; @@ -29,7 +30,7 @@ describe('pairs fetching (e2e)', () => { beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], + imports: [TokensModule, PairsModule], }).compile(); app = moduleFixture.createNestApplication(); diff --git a/test/swap-routes.e2e-spec.ts b/test/swap-routes.e2e-spec.ts index 127c945..7cbcfd5 100644 --- a/test/swap-routes.e2e-spec.ts +++ b/test/swap-routes.e2e-spec.ts @@ -1,12 +1,13 @@ import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; import * as request from 'supertest'; -import { AppModule } from '../src/app.module'; -import { mockContext, listToken } from './utils'; +import { listToken, mockContext } from './utils'; import worker from '../src/worker'; import * as db from './utils/db'; import * as data from './data/context-mockups'; +import { TokensModule } from '../src/api/tokens/module'; +import { PairsModule } from '../src/api/pairs/module'; type WorkerMethods = ReturnType; let activeWorker: WorkerMethods; @@ -28,7 +29,7 @@ const initWorker = async (dataCtx: any) => { const initApp = async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], + imports: [TokensModule, PairsModule], }).compile(); app = moduleFixture.createNestApplication(); diff --git a/test/tokens.e2e-spec.ts b/test/tokens.e2e-spec.ts index e33ac85..08646e3 100644 --- a/test/tokens.e2e-spec.ts +++ b/test/tokens.e2e-spec.ts @@ -1,7 +1,6 @@ import { Test, TestingModule } from '@nestjs/testing'; import { INestApplication } from '@nestjs/common'; import * as request from 'supertest'; -import { AppModule } from '../src/app.module'; import worker from '../src/worker'; import { clean as cleanDb } from './utils/db'; @@ -9,6 +8,8 @@ import * as data from './data/context-mockups'; import * as dto from '../src/dto'; import * as utils from './utils'; import { nonNullable } from '../src/lib/utils'; +import { TokensModule } from '../src/api/tokens/module'; +import { PairsModule } from '../src/api/pairs/module'; type WorkerMethods = ReturnType; let activeWorker: WorkerMethods; @@ -32,7 +33,7 @@ describe('tokens fetching (e2e)', () => { beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], + imports: [TokensModule, PairsModule], }).compile(); app = moduleFixture.createNestApplication(); @@ -486,7 +487,7 @@ describe('listed tokens management (e2e)', () => { beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [AppModule], + imports: [TokensModule, PairsModule], }).compile(); app = moduleFixture.createNestApplication();