Files
proxmox/multi-chain-execution/scripts/integration-test.mjs
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

78 lines
2.6 KiB
JavaScript

#!/usr/bin/env node
/**
* Minimal integration test for multi-chain execution API.
* Creates intent 138 -> 651940, executes, and verifies execution.
* Assumes deterministic contract addresses: same address on 138 and 651940 (CREATE2).
* Run with: BASE_URL=http://localhost:3001 node scripts/integration-test.mjs
* Prerequisite: npm run build && npm start (in another terminal).
*/
const BASE = process.env.BASE_URL || 'http://localhost:3001';
async function request(method, path, body = null) {
const opts = { method, headers: {} };
if (body) {
opts.headers['Content-Type'] = 'application/json';
opts.body = JSON.stringify(body);
}
const res = await fetch(`${BASE}${path}`, opts);
const text = await res.text();
if (!res.ok) throw new Error(`${res.status} ${path}: ${text}`);
return text ? JSON.parse(text) : {};
}
async function main() {
console.log('Integration test (138 -> 651940, deterministic addresses assumed)\n');
const health = await request('GET', '/v1/health');
console.log('Health:', health.status, health.circuit_breaker);
if (health.status !== 'ok' && health.status !== 'degraded') {
throw new Error('Health check failed');
}
const intentPayload = {
type: 'cross_chain',
chain_from: 138,
chain_to: 651940,
asset_in: 'native',
asset_out: 'native',
amount: '1000000',
idempotency_key: `integration-${Date.now()}`,
};
const intent = await request('POST', '/v1/intents', intentPayload);
if (!intent.intent_id) throw new Error('No intent_id');
console.log('Intent created:', intent.intent_id);
const exec = await request('POST', `/v1/intents/${intent.intent_id}/execute`);
if (!exec.execution_id) throw new Error('No execution_id');
console.log('Execution started:', exec.execution_id);
const execution = await request('GET', `/v1/executions/${exec.execution_id}`);
console.log('Execution status:', execution.status || execution);
const commitPayload = {
chain_id: 138,
leaves: [{
chainId: 138,
txHash: '0x' + '0'.repeat(64),
blockNumber: '100',
receiptRootOrLogsBloom: '0x00',
normalizedEventPayloadHash: '0x00',
salJournalEntryHash: null,
}],
uri: 'https://example.com/leaves',
};
const commit = await request('POST', '/v1/mirror/commit', commitPayload);
if (commit.commit_id) {
const got = await request('GET', `/v1/mirror/commits/${commit.commit_id}`);
console.log('Mirror commit verified:', got.commit_id === commit.commit_id);
}
console.log('\nIntegration test OK (deterministic addresses assumed for 138 and 651940).');
}
main().catch((err) => {
console.error(err);
process.exit(1);
});