feat(paper): gate canonical execution on durable feed readiness
This commit is contained in:
parent
c01e96e4dd
commit
75abae2cfc
24 changed files with 3720 additions and 66 deletions
45
test/integration/paper-composition.test.ts
Normal file
45
test/integration/paper-composition.test.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { asFunction, createContainer as createDiContainer } from 'awilix';
|
||||
import { expect, test } from 'bun:test';
|
||||
import type { ServiceCradle } from '@stock-bot/di';
|
||||
import type { StockAppConfig } from '@stock-bot/stock-config';
|
||||
import { registerOrchestratorServices } from '../../apps/stock/orchestrator/src/container';
|
||||
import { createContainer } from '../../apps/stock/orchestrator/src/simple-container';
|
||||
import { paperFeedConfiguration } from '../fixtures/paper-feed';
|
||||
|
||||
test('canonical paper rejects invalid role/configuration before resolving services', async () => {
|
||||
let resolved = 0;
|
||||
const container = createDiContainer<ServiceCradle>();
|
||||
container.register({
|
||||
serviceContainer: asFunction(() => {
|
||||
resolved++;
|
||||
throw new Error('Unexpected service resolution');
|
||||
}),
|
||||
});
|
||||
const config = paperFeedConfiguration();
|
||||
await expect(
|
||||
registerOrchestratorServices(container, {
|
||||
role: 'research-only',
|
||||
canonicalPaper: config,
|
||||
})
|
||||
).rejects.toThrow('requires a paper composition');
|
||||
config.matching.series[0]!.mode = 'Open';
|
||||
await expect(
|
||||
registerOrchestratorServices(container, {
|
||||
canonicalPaper: config,
|
||||
})
|
||||
).rejects.toThrow('Quote execution only');
|
||||
expect(resolved).toBe(0);
|
||||
});
|
||||
|
||||
test('live defaults, research canonical configuration and missing custody fail before connections', async () => {
|
||||
const config = (orchestrator: unknown) => ({ services: { orchestrator } }) as StockAppConfig;
|
||||
await expect(createContainer(config({ defaultMode: 'live' }))).rejects.toThrow(
|
||||
'Live trading is disabled'
|
||||
);
|
||||
await expect(
|
||||
createContainer(config({ defaultMode: 'backtest', canonicalPaper: paperFeedConfiguration() }))
|
||||
).rejects.toThrow('requires a paper composition');
|
||||
await expect(
|
||||
createContainer(config({ canonicalPaper: paperFeedConfiguration() }))
|
||||
).rejects.toThrow('requires durable PostgreSQL');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue