UNPKG

@lit-protocol/e2e

Version:

Lit Protocol E2E testing package for running comprehensive integration tests

144 lines โ€ข 6.66 kB
/** * Naga Health Check Runner * * This is the main entry point for running health checks on Naga networks. * It initializes the environment, runs all endpoint tests, and logs results * to the Lit Status backend for monitoring. * * Environment Variables Required: * - NETWORK: The network to test (naga-dev or naga-test) * - LIVE_MASTER_ACCOUNT: Private key of the master funding account * - LIT_STATUS_BACKEND_URL: URL of the status backend * - LIT_STATUS_WRITE_KEY: API key for writing to status backend * * Optional: * - LOG_LEVEL: Logging verbosity (silent, info, debug) * - LIT_YELLOWSTONE_PRIVATE_RPC_URL: Override RPC URL * * Usage: * NETWORK=naga-dev pnpm run ci:health * NETWORK=naga-test pnpm run test:health */ import { initHealthCheck } from './health-init'; import { NagaHealthManager } from './NagaHealthManager'; // Configuration from environment const NETWORK = process.env['NETWORK']; const PRODUCT = 'js-sdk/naga'; /** * Validate required environment variables */ function validateEnvironment() { console.log('๐Ÿ” Environment Variables:'); console.log(' NETWORK:', process.env['NETWORK']); console.log(' LIT_STATUS_BACKEND_URL:', process.env['LIT_STATUS_BACKEND_URL']); console.log(' LIT_STATUS_WRITE_KEY:', process.env['LIT_STATUS_WRITE_KEY'] ? '[SET]' : '[NOT SET]'); console.log(' LIVE_MASTER_ACCOUNT:', process.env['LIVE_MASTER_ACCOUNT'] ? '[SET]' : '[NOT SET]'); if (!NETWORK) { throw new Error('โŒ NETWORK environment variable is not set'); } if (!process.env['LIT_STATUS_BACKEND_URL']) { throw new Error('โŒ LIT_STATUS_BACKEND_URL environment variable is not set'); } if (!process.env['LIT_STATUS_WRITE_KEY']) { throw new Error('โŒ LIT_STATUS_WRITE_KEY environment variable is not set'); } if (!process.env['LIVE_MASTER_ACCOUNT']) { throw new Error('โŒ LIVE_MASTER_ACCOUNT environment variable is not set'); } console.log('โœ… All required environment variables are set\n'); } /** * Main health check execution */ async function runHealthCheck() { // Validate environment validateEnvironment(); console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); console.log('๐Ÿฅ Naga Health Check Starting'); console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); console.log(`Network: ${NETWORK}`); console.log(`Product: ${PRODUCT}`); console.log(`Time: ${new Date().toISOString()}\n`); // Initialize Lit Status Client (dynamic import for ESM compatibility) const { createLitStatusClient } = await import('@lit-protocol/lit-status-sdk'); const statusClient = createLitStatusClient({ url: process.env['LIT_STATUS_BACKEND_URL'], apiKey: process.env['LIT_STATUS_WRITE_KEY'], }); console.log('โœ… Lit Status Client initialized\n'); // Register or get function IDs for tracking console.log('๐Ÿ“ Registering health check functions...'); const txs = await statusClient.getOrRegisterFunctions({ network: NETWORK, product: PRODUCT, functions: [ 'handshake', 'pkpSign', 'signSessionKey', 'executeJs', 'decrypt', 'wrappedKeys', ], }); console.log('โœ… Functions registered\n'); // Initialize health check environment console.log('๐Ÿš€ Initializing health check environment...'); console.log('โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€'); const ctx = await initHealthCheck(); console.log('โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n'); // Create health manager const healthManager = new NagaHealthManager(ctx); // Run tests and log results console.log('๐Ÿงช Running Health Check Tests'); console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n'); // Test 1: Handshake console.log('1๏ธโƒฃ Testing: Handshake'); await statusClient.executeAndLog(txs.handshake.id, healthManager.handshakeTest); console.log(''); // Test 2: PKP Sign console.log('2๏ธโƒฃ Testing: PKP Sign'); await statusClient.executeAndLog(txs.pkpSign.id, healthManager.pkpSignTest); console.log(''); // Test 3: Sign Session Key console.log('3๏ธโƒฃ Testing: Sign Session Key'); await statusClient.executeAndLog(txs.signSessionKey.id, healthManager.signSessionKeyTest); console.log(''); // Test 4: Execute JS console.log('4๏ธโƒฃ Testing: Execute JS (Lit Actions)'); await statusClient.executeAndLog(txs.executeJs.id, healthManager.executeJsTest); console.log(''); // Test 5: Decrypt console.log('5๏ธโƒฃ Testing: Encrypt/Decrypt'); await statusClient.executeAndLog(txs.decrypt.id, healthManager.decryptTest); console.log(''); // Test 6: Wrapped Keys console.log('6๏ธโƒฃ Testing: Wrapped Keys Service'); await statusClient.executeAndLog(txs.wrappedKeys.id, healthManager.wrappedKeysTest); console.log(''); console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); console.log('โœ… Health Check Completed Successfully'); console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); console.log(`Network: ${NETWORK}`); console.log(`Time: ${new Date().toISOString()}`); console.log('All 6 endpoint tests passed โœจ\n'); } /** * Entry point with error handling */ (async () => { try { await runHealthCheck(); process.exit(0); } catch (error) { console.error('\nโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); console.error('โŒ Health Check Failed'); console.error('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); console.error('Error:', error); console.error('Network:', NETWORK); console.error('Time:', new Date().toISOString()); console.error('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n'); process.exit(1); } })(); //# sourceMappingURL=index.js.map