add ConnectURI class

This commit is contained in:
tiero
2023-01-03 00:52:04 +01:00
parent 140190699f
commit 0a85d00deb
9 changed files with 259 additions and 506 deletions

33
test/rpc.test.ts Normal file
View File

@@ -0,0 +1,33 @@
import { NostrRPC } from '../src/rpc';
import { sleep } from './utils';
class Server extends NostrRPC {
async ping(): Promise<string> {
return 'pong';
}
}
jest.setTimeout(5000);
describe('Nostr RPC', () => {
it('starts a server', async () => {
const server = new Server({
secretKey:
'ed779ff047f99c95f732b22c9f8f842afb870c740aab591776ebc7b64e83cf6c',
});
await server.listen();
const client = new NostrRPC({
secretKey:
'5acff99d1ad3e1706360d213fd69203312d9b5e91a2d5f2e06100cc6f686e5b3',
});
await sleep(2000);
const result = await client.call({
target: server.self.pubkey,
request: { method: 'ping' },
});
expect(result).toBe('pong');
});
});