Files
smom-dbis-138/test/emoney/api/contract/event-schema-validation.test.ts
defiQUG 1fb7266469 Add Oracle Aggregator and CCIP Integration
- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control.
- Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities.
- Created .gitmodules to include OpenZeppelin contracts as a submodule.
- Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment.
- Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks.
- Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring.
- Created scripts for resource import and usage validation across non-US regions.
- Added tests for CCIP error handling and integration to ensure robust functionality.
- Included various new files and directories for the orchestration portal and deployment scripts.
2025-12-12 14:57:48 -08:00

65 lines
1.9 KiB
TypeScript

/**
* Event Schema Validation Tests
* Ensures events conform to AsyncAPI specification
*/
import { describe, it, expect } from '@jest/globals';
import { readFileSync } from 'fs';
import { join } from 'path';
import * as yaml from 'js-yaml';
import Ajv from 'ajv';
import addFormats from 'ajv-formats';
const ASYNCAPI_SPEC = join(__dirname, '../../../api/packages/asyncapi/asyncapi.yaml');
describe('AsyncAPI Event Schema Validation', () => {
let asyncapiSpec: any;
let ajv: Ajv;
beforeAll(() => {
const specContent = readFileSync(ASYNCAPI_SPEC, 'utf-8');
asyncapiSpec = yaml.load(specContent);
ajv = new Ajv();
addFormats(ajv);
});
it('should have valid AsyncAPI structure', () => {
expect(asyncapiSpec).toHaveProperty('asyncapi');
expect(asyncapiSpec.asyncapi).toMatch(/^3\.\d+\.\d+$/);
expect(asyncapiSpec).toHaveProperty('channels');
});
it('should have all required event channels', () => {
const requiredChannels = [
'triggers.created',
'triggers.state.updated',
'liens.placed',
'liens.reduced',
'liens.released',
'packets.generated',
'packets.dispatched',
'packets.acknowledged',
'bridge.locked',
'bridge.unlocked',
'compliance.updated',
'policy.updated',
];
requiredChannels.forEach((channel) => {
expect(asyncapiSpec.channels).toHaveProperty(channel);
});
});
it('should have event envelope schema', () => {
expect(asyncapiSpec.components).toHaveProperty('schemas');
expect(asyncapiSpec.components.schemas).toHaveProperty('EventEnvelope');
const envelopeSchema = asyncapiSpec.components.schemas.EventEnvelope;
expect(envelopeSchema.required).toContain('eventId');
expect(envelopeSchema.required).toContain('eventType');
expect(envelopeSchema.required).toContain('occurredAt');
expect(envelopeSchema.required).toContain('payload');
});
});