-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-rpc.js
More file actions
51 lines (39 loc) · 1.3 KB
/
test-rpc.js
File metadata and controls
51 lines (39 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
/**
* TEST DELTACHAT RPC CONNECTION
*/
import { Server } from '@deltachat/jsonrpc-client';
async function testConnection() {
console.log('Testing Delta Chat RPC connection...');
try {
const client = new Server({
transport: 'stdio',
});
console.log('✓ Client created');
// Wait for initial connection
await new Promise((resolve) => setTimeout(resolve, 2000));
console.log('✓ Connected (waited 2s)');
// Get next event to verify connection
const events = await client.getNextEventBatch();
console.log(`✓ Received ${events.length} event(s)`);
// Try to get accounts
const accounts = await client.getAllAccounts();
console.log(`✓ Found ${accounts.length} account(s)`);
for (const account of accounts) {
console.log(`\nAccount ${account.id}:`);
console.log(` Email: ${account.addr}`);
// Try to get transports
try {
const transports = await client.listTransports(account.id);
console.log(` Transports: ${transports.length}`);
} catch (e) {
console.log(` Transports error: ${e.message}`);
}
}
console.log('\n✅ SUCCESS: Delta Chat RPC is working!');
} catch (error) {
console.error('\n❌ ERROR:', error.message);
process.exit(1);
}
}
testConnection();