Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,28 @@ module.exports = {
'^@types/(.*)$': '<rootDir>/src/types/$1',
},
transform: {
'^.+\\.ts$': ['ts-jest', {
'^.+\\.(ts|tsx)$': ['ts-jest', {
tsconfig: {
target: 'ES2022',
module: 'commonjs',
esModuleInterop: true,
skipLibCheck: true,
strict: true,
resolveJsonModule: true,
allowJs: true,
},
}],
'^.+\\.(js|jsx)$': ['ts-jest', {
tsconfig: {
target: 'ES2022',
module: 'commonjs',
esModuleInterop: true,
skipLibCheck: true,
allowJs: true,
},
}],
},
transformIgnorePatterns: [
'node_modules/(?!(@paradex|@polymarket)/)',
],
};
8 changes: 8 additions & 0 deletions src/services/signal/llm-analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ function getRateLimiter(model: string) {
});
}

/**
* Reset all circuit breakers (for testing)
*/
export function resetCircuitBreakers(): void {
circuitBreakers.forEach(cb => cb.reset());
circuitBreakers.clear();
}

// =============================================================================
// ENTRY ANALYSIS
// =============================================================================
Expand Down
9 changes: 8 additions & 1 deletion tests/integration/live-trading-resilience.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Tests system behavior under LLM failures
*/

import { analyzeEntry } from '../../src/services/signal/llm-analyzer';
import { analyzeEntry, resetCircuitBreakers } from '../../src/services/signal/llm-analyzer';
import type { TechnicalIndicators, Kline } from '../../src/types';

// Mock fetch
Expand Down Expand Up @@ -45,6 +45,12 @@ jest.mock('../../src/utils/logger', () => ({
warn: jest.fn(),
info: jest.fn(),
},
logger: {
debug: jest.fn(),
warn: jest.fn(),
info: jest.fn(),
error: jest.fn(),
},
}));

// Mock metrics
Expand Down Expand Up @@ -109,6 +115,7 @@ describe('Live Trading Resilience', () => {
beforeEach(() => {
jest.clearAllMocks();
(global.fetch as jest.Mock).mockClear();
resetCircuitBreakers(); // Reset circuit breaker state between tests
});

describe('System continues trading with LLM failures', () => {
Expand Down
9 changes: 8 additions & 1 deletion tests/integration/llm-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Tests end-to-end LLM integration with retry, circuit breaker, and rate limiting
*/

import { analyzeEntry, analyzeExit } from '../../src/services/signal/llm-analyzer';
import { analyzeEntry, analyzeExit, resetCircuitBreakers } from '../../src/services/signal/llm-analyzer';
import type { TechnicalIndicators, Position, Kline } from '../../src/types';

// Mock fetch
Expand Down Expand Up @@ -45,6 +45,12 @@ jest.mock('../../src/utils/logger', () => ({
warn: jest.fn(),
info: jest.fn(),
},
logger: {
debug: jest.fn(),
warn: jest.fn(),
info: jest.fn(),
error: jest.fn(),
},
}));

// Mock metrics
Expand Down Expand Up @@ -127,6 +133,7 @@ describe('LLM Integration', () => {
beforeEach(() => {
jest.clearAllMocks();
(global.fetch as jest.Mock).mockClear();
resetCircuitBreakers(); // Reset circuit breaker state between tests
});

describe('End-to-end entry analysis', () => {
Expand Down
Loading
Loading