tasq/node_modules/agentic-flow/validation/test-quic-wasm.ts

95 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* QUIC WASM Integration Test
*
* Validates that the QUIC transport WASM module loads correctly
* and provides the expected API surface.
*/
import { existsSync } from 'fs';
import { join } from 'path';
async function testQuicWasmIntegration() {
console.log('🧪 Testing QUIC WASM Integration...\n');
try {
// Test 1: Load WASM module
console.log('1⃣ Loading WASM module...');
// Try both production and development paths
const prodPath = join(process.cwd(), 'wasm/quic/agentic_flow_quic.js');
const devPath = join(process.cwd(), '../crates/agentic-flow-quic/pkg/agentic_flow_quic.js');
let wasmPath: string;
if (existsSync(prodPath)) {
wasmPath = prodPath;
} else if (existsSync(devPath)) {
wasmPath = devPath;
} else {
throw new Error(`WASM module not found at ${prodPath} or ${devPath}`);
}
console.log(` Loading from: ${wasmPath}`);
const wasm = await import(wasmPath);
console.log(' ✅ WASM module loaded successfully');
// Test 2: Check exports
console.log('\n2⃣ Checking exports...');
const requiredExports = [
'WasmQuicClient',
'createQuicMessage',
'defaultConfig'
];
for (const exportName of requiredExports) {
if (wasm[exportName]) {
console.log(`${exportName} exported`);
} else {
throw new Error(`Missing export: ${exportName}`);
}
}
// Test 3: Create default config
console.log('\n3⃣ Creating default config...');
const config = wasm.defaultConfig();
console.log(' ✅ Default config created:', config);
// Test 4: Create QUIC message
console.log('\n4⃣ Creating QUIC message...');
const message = wasm.createQuicMessage(
'test-msg-1',
'task',
new TextEncoder().encode(JSON.stringify({ action: 'test' })),
null
);
console.log(' ✅ QUIC message created:', message);
console.log('\n✅ All QUIC WASM integration tests passed!\n');
console.log('📊 Summary:');
console.log(' - WASM module: loaded');
console.log(' - Exports: verified');
console.log(' - Config creation: working');
console.log(' - Message creation: working');
console.log('\n⚠ Note: This WASM build uses stubs. For full QUIC functionality, use native Node.js builds.\n');
return { success: true };
} catch (error) {
console.error('\n❌ QUIC WASM integration test failed:', error);
if (error instanceof Error) {
console.error(' Error:', error.message);
console.error(' Stack:', error.stack);
}
return { success: false, error };
}
}
// Run tests
testQuicWasmIntegration()
.then(result => {
process.exit(result.success ? 0 : 1);
})
.catch(err => {
console.error('Unexpected error:', err);
process.exit(1);
});