Skip to content

Commit

Permalink
feat: Programmatically access RPC.
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenyoung committed Nov 28, 2024
1 parent 037d2e7 commit e4b961e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Orbiter from './lib/orbiter.js'
import Lander from './lib/lander.js'
import RPC from './rpc-client.js'

export {
Orbiter,
Lander
Lander,
RPC
}
38 changes: 38 additions & 0 deletions test/rpc.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { deepStrictEqual } from 'assert'
import { rimraf } from 'rimraf'
import { RPC } from '../src/index.js'
import { spawn } from 'node:child_process'
import waitForDaemonStarted from './utils/wait-for-daemon-start.js'

describe('RPC', function () {
let daemon
let rpc

before(async function () {
daemon = spawn('./src/bin/cli.js', ['daemon'])

await waitForDaemonStarted(daemon)

rpc = await RPC({ directory: '' })
})

after(async function () {
daemon.kill()
await rimraf('voyager')
})

it('adds an authorized user', async function () {
const id = '037ba2545db2e2ec0ba17fc9b35fbbf6bc09db82c9ab324521e62693e8aa96ceb4'
await rpc.authAdd({ id })
const { message } = await rpc.authList()
deepStrictEqual(message, [id])
})

it('removes an authorized user', async function () {
const id = '037ba2545db2e2ec0ba17fc9b35fbbf6bc09db82c9ab324521e62693e8aa96ceb4'
await rpc.authAdd({ id })
await rpc.authDel({ id })
const { message } = await rpc.authList()
deepStrictEqual(message, [])
})
})

0 comments on commit e4b961e

Please sign in to comment.