Initial project setup: Add contracts, API definitions, tests, and documentation
- Add Foundry project configuration (foundry.toml, foundry.lock) - Add Solidity contracts (TokenFactory138, BridgeVault138, ComplianceRegistry, etc.) - Add API definitions (OpenAPI, GraphQL, gRPC, AsyncAPI) - Add comprehensive test suite (unit, integration, fuzz, invariants) - Add API services (REST, GraphQL, orchestrator, packet service) - Add documentation (ISO20022 mapping, runbooks, adapter guides) - Add development tools (RBC tool, Swagger UI, mock server) - Update OpenZeppelin submodules to v5.0.0
This commit is contained in:
91
test/api/integration/graphql.test.ts
Normal file
91
test/api/integration/graphql.test.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* GraphQL API Integration Tests
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeAll } from '@jest/globals';
|
||||
import { GraphQLClient } from 'graphql-request';
|
||||
|
||||
const GRAPHQL_URL = process.env.GRAPHQL_URL || 'http://localhost:4000/graphql';
|
||||
|
||||
describe('GraphQL API Integration Tests', () => {
|
||||
let client: GraphQLClient;
|
||||
|
||||
beforeAll(() => {
|
||||
client = new GraphQLClient(GRAPHQL_URL, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${process.env.ACCESS_TOKEN || 'test-token'}`,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
describe('Queries', () => {
|
||||
it('should query token', async () => {
|
||||
const query = `
|
||||
query GetToken($code: String!) {
|
||||
token(code: $code) {
|
||||
code
|
||||
address
|
||||
name
|
||||
symbol
|
||||
policy {
|
||||
lienMode
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const data = await client.request(query, { code: 'USDW' });
|
||||
expect(data).toHaveProperty('token');
|
||||
expect(data.token).toHaveProperty('code');
|
||||
});
|
||||
|
||||
it('should query triggers', async () => {
|
||||
const query = `
|
||||
query GetTriggers($filter: TriggerFilter, $paging: Paging) {
|
||||
triggers(filter: $filter, paging: $paging) {
|
||||
items {
|
||||
triggerId
|
||||
rail
|
||||
state
|
||||
}
|
||||
total
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const data = await client.request(query, {
|
||||
filter: { state: 'PENDING' },
|
||||
paging: { limit: 10, offset: 0 },
|
||||
});
|
||||
|
||||
expect(data).toHaveProperty('triggers');
|
||||
expect(data.triggers).toHaveProperty('items');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Mutations', () => {
|
||||
it('should deploy token via mutation', async () => {
|
||||
const mutation = `
|
||||
mutation DeployToken($input: DeployTokenInput!) {
|
||||
deployToken(input: $input) {
|
||||
code
|
||||
address
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const data = await client.request(mutation, {
|
||||
input: {
|
||||
name: 'Test Token',
|
||||
symbol: 'TEST',
|
||||
decimals: 18,
|
||||
issuer: '0x1234567890123456789012345678901234567890',
|
||||
},
|
||||
});
|
||||
|
||||
expect(data).toHaveProperty('deployToken');
|
||||
expect(data.deployToken).toHaveProperty('code');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
105
test/api/integration/rest-api.test.ts
Normal file
105
test/api/integration/rest-api.test.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* REST API Integration Tests
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeAll, afterAll } from '@jest/globals';
|
||||
import axios from 'axios';
|
||||
|
||||
const BASE_URL = process.env.API_URL || 'http://localhost:3000';
|
||||
const API_KEY = process.env.API_KEY || 'test-key';
|
||||
|
||||
describe('REST API Integration Tests', () => {
|
||||
let accessToken: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
// TODO: Get OAuth2 token
|
||||
// accessToken = await getAccessToken();
|
||||
});
|
||||
|
||||
describe('Token Operations', () => {
|
||||
it('should deploy a token', async () => {
|
||||
const response = await axios.post(
|
||||
`${BASE_URL}/v1/tokens`,
|
||||
{
|
||||
name: 'Test Token',
|
||||
symbol: 'TEST',
|
||||
decimals: 18,
|
||||
issuer: '0x1234567890123456789012345678901234567890',
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
'Idempotency-Key': `test-${Date.now()}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(response.status).toBe(201);
|
||||
expect(response.data).toHaveProperty('code');
|
||||
expect(response.data).toHaveProperty('address');
|
||||
});
|
||||
|
||||
it('should list tokens', async () => {
|
||||
const response = await axios.get(`${BASE_URL}/v1/tokens`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.data).toHaveProperty('items');
|
||||
expect(Array.isArray(response.data.items)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Lien Operations', () => {
|
||||
it('should place a lien', async () => {
|
||||
const response = await axios.post(
|
||||
`${BASE_URL}/v1/liens`,
|
||||
{
|
||||
debtor: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
|
||||
amount: '1000000000000000000',
|
||||
priority: 1,
|
||||
reasonCode: 'DEBT_ENFORCEMENT',
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(response.status).toBe(201);
|
||||
expect(response.data).toHaveProperty('lienId');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ISO-20022 Operations', () => {
|
||||
it('should submit outbound message', async () => {
|
||||
const response = await axios.post(
|
||||
`${BASE_URL}/v1/iso/outbound`,
|
||||
{
|
||||
msgType: 'pacs.008',
|
||||
instructionId: `0x${'1'.repeat(64)}`,
|
||||
payloadHash: `0x${'a'.repeat(64)}`,
|
||||
payload: '<Document>...</Document>',
|
||||
rail: 'FEDWIRE',
|
||||
token: '0x1234567890123456789012345678901234567890',
|
||||
amount: '1000000000000000000',
|
||||
accountRefId: `0x${'b'.repeat(64)}`,
|
||||
counterpartyRefId: `0x${'c'.repeat(64)}`,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
'Idempotency-Key': `test-${Date.now()}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
expect(response.status).toBe(201);
|
||||
expect(response.data).toHaveProperty('triggerId');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user