const WebSocket = require('ws'); const ws = new WebSocket('ws://146.56.248.142:8083/ws?password=wzw20040525'); let fileId = 'test_' + Date.now(); const testContent = Buffer.from('Hello Remote Test'); ws.on('open', () => { console.log('=== Connected to 146.56.248.142:8083 ==='); ws.send(JSON.stringify({ type: 'fileUploadStart', fileId: fileId, filename: 'test.txt', totalChunks: 1, fileSize: testContent.length, requestId: 'req1' })); }); ws.on('message', (data, isBinary) => { if (isBinary) return; const msg = JSON.parse(data.toString()); console.log('Received:', msg.type); if (msg.type === 'fileUploadStart') { ws.send(JSON.stringify({ type: 'fileUploadChunk', fileId: fileId, chunkIndex: 0, data: testContent.toString('base64'), requestId: 'req2' })); } if (msg.type === 'fileUploadChunk') { ws.send(JSON.stringify({ type: 'fileUploadMerge', fileId: fileId, filename: 'test.txt', totalChunks: 1, requestId: 'req3' })); } if (msg.type === 'fileUploadResult') { console.log('=== Upload:', msg.success ? 'SUCCESS' : 'FAILED'); if (msg.success) { ws.send(JSON.stringify({ type: 'fileDownloadStart', filename: 'test.txt', filePath: 'test.txt', allowSystem: false, requestId: 'req4' })); } else { ws.close(); process.exit(1); } } if (msg.type === 'fileDownloadComplete') { console.log('=== Download:', msg.success ? 'SUCCESS' : 'FAILED'); console.log('=== ALL TESTS PASSED ==='); ws.close(); process.exit(0); } }); ws.on('error', err => console.error('Error:', err.message)); setTimeout(() => { console.log('TIMEOUT'); process.exit(1); }, 15000);