-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-rpc-stdio.js
More file actions
52 lines (40 loc) · 1.34 KB
/
test-rpc-stdio.js
File metadata and controls
52 lines (40 loc) · 1.34 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
52
#!/usr/bin/env node
/**
* TEST DELTACHAT RPC CONNECTION (STDIO)
*/
import { RawClient } from '@deltachat/jsonrpc-client';
async function testConnection() {
console.log('Testing Delta Chat RPC connection via stdio...');
try {
const client = new RawClient({
transport: 'stdio',
});
console.log('✓ Client created with RawClient');
// Wait for initial connection
await new Promise((resolve) => setTimeout(resolve, 2000));
console.log('✓ Connected');
// Get next event
const event = await client.getNextEvent();
console.log(`✓ Received event: ${JSON.stringify(event)}`);
// 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);
console.error(error.stack);
process.exit(1);
}
}
testConnection();